用废弃的开放连接彗星问题 [英] Comet issue with abandoned open connections

查看:177
本文介绍了用废弃的开放连接彗星问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的一些彗星的技术,包括长轮询和永远的框架。我使用的内置页框跨子域的东西。我遇到了在实施这些技术是当用户刷新页面或导航到另一个页面造成新的请求的一个问题,彗星连接保持从旧的页面打开。我的服务器(龙卷风)永远不会收到一个连接关闭,并从我有限的Wireshark的能力我没有看到任何TCP FIN数据包发送。然而,当我关闭浏览器时,插座收于该点。

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.

这些废弃的开放连接只是使用内存在服务器端没有很好的理由。此外,它会导致问题,因为服务器发送一些信息到打开的插座和IE然后正确地显示一条错误消息:不能从已释放脚本执行code。因此,IE是试图执行code对旧的窗口这是导航离开。如何其他人处理这个问题?我应该用onbeforeunload的以某种方式关闭连接?

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?

推荐答案

您可以飘飞重新打开连接从客户端,如果请求不进来的服务器在指定的时间框架,你可以安全地关闭旧的连接。

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.

这篇关于用废弃的开放连接彗星问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆