Comet 问题与废弃的开放连接

发布于 2024-10-12 05:32:19 字数 351 浏览 13 评论 0原文

我正在使用一些彗星技术,包括长轮询和永远帧。我正在使用 iframe 进行跨子域的操作。我在实现这些技术时遇到的一个问题是,当用户刷新页面或导航到另一个页面导致新请求时,彗星连接从旧页面保持打开状态。我的服务器(龙卷风)从未收到关闭连接,并且从我有限的wireshark能力来看,我没有看到任何发送的TCP fin数据包。但是,当我关闭浏览器时,套接字将在此时关闭。

这些废弃的打开连接只是无缘无故地耗尽了服务器端的内存。当服务器向打开的套接字发送一些消息并且 IE 然后正确显示错误消息时,它也会导致问题:“无法从释放的脚本执行代码”。因此 IE 试图在导航离开的旧窗口上执行代码。其他人如何处理这个问题?我应该使用 onbeforeunload 以某种方式关闭连接吗?

I am using some comet techniques including long polling and forever frame. I am using iframes for cross subdomain stuff. The one issue that I ran into while implementing these techniques is when a user refreshes a page or navigates to another page causing a new request, the comet connection is kept open from the old page. My server (tornado) never receives a connection close and from my limited wireshark abilities I don't see any TCP fin packet sent. However, when I close the the browser, the sockets are closed at that point.

These abandoned open connections are just using up memory on the server side for no good reason. Also it causes problems when the server sends some message to the open socket and IE then correctly displays an error message: "Can't execute code from a freed script". So IE is trying to execute code on the old window which was navigated away from. How are other people handling this issue? Should I use onbeforeunload to somehow close the connection?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七分※倦醒 2024-10-19 05:32:19

您可以时不时地从客户端重新启动打开的连接,如果请求没有在指定的时间范围内到达服务器,您可以安全地关闭旧连接。

You could restart an open connection every now and then from the client side and if the request did not come in to the server in the specified time-frame you can safely close the old connection.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文