Opera 将长轮询套接字保持打开状态

发布于 2024-10-15 10:34:39 字数 560 浏览 7 评论 0原文

我们在长轮询和歌剧方面遇到了问题。我本人是一名 C 程序员,并根据我们的需求开发了一个定制的 http 守护进程。在这种情况下,我们需要一个能够处理大量连接的长轮询服务器。

问题是,歌剧以某种方式让这些长时间的民意调查打开,即使在点击网站上的某个链接之后,当然也会打开新的民意调查。我们使用基本的长轮询技术,尝试将 javascript 包含在 iframe 中。这对于其他浏览器来说效果很好,但即使我强制之前的民意调查在服务器端关闭,opera 也会重新打开它们。这不是很好,因为在高流量网站上,只有少数 Opera 用户只需浏览网站就可以导致守护进程快速耗尽可用文件描述符(因为网站上的每次点击都会打开一个新的长轮询,而旧的轮询不会关闭) )。页面刷新不会导致相同的情况,它做了正确的事情:关闭长轮询并打开一个新轮询。关闭 Opera 后,所有文件描述符都被关闭,一切都恢复正常。

那么,我应该在 http-daemon 中为 opera 添加一些特定的标头,还是我们的 javascript 有问题?

编辑:测试使用版本:Opera/9.80 (X11; Linux x86_64; U; en) Presto/2.6.30 Version/10.63

We have a problem with long polling and opera. I myself am a c-programmer and have developed a customized http-daemon for our needs. In this case we needed a long polling server that would be able to handle large amounts of connections.

The problem is that opera somehow leaves these long polls open even after clicking some link on the site and of course opens new one. We use basic long polling technique which tries to include javascript inside iframe. This works fine with other browsers, but even if I force previous polls to close on server side, opera reopens them. This is not very good, because on high traffic site, just few opera users can cause the daemon to quickly run out of free file descriptors simply by browsing the site (because every click on the site opens a new long poll and old ones wont close). Page refresh does not cause the same, it does the right thing: close the long poll and open a new one. After closing opera, all file descriptors are closed and everything is fine again.

So, should I add some specific headers for opera in the http-daemon or is there something wrong in our javascript?

edit: Tested using version: Opera/9.80 (X11; Linux x86_64; U; en) Presto/2.6.30 Version/10.63

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

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

发布评论

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

评论(2

情绪操控生活 2024-10-22 10:34:39

我们使用基本的长轮询技术,尝试在 iframe 中包含 JavaScript。

那么有问题的套接字正在向 iframe 提供内容?

如果您单击离开该页面,Opera 似乎确实应该关闭这些连接。但是您可能会在离开页面时尝试显式销毁 iframes ,例如:(

window.onbeforeunload = function() {
    theIframe.parentNode.removeChild(theIframe);
    theIframe = undefined;
};

我假设您有对位于某处的 iframe 的引用。)

编辑:或者甚至导航首先是其他地方的 iframe:

window.onbeforeunload = function() {
    theIframe.src = "about:blank";             // <== New bit
    theIframe.parentNode.removeChild(theIframe);
    theIframe = undefined;
};

We use basic long polling technique which tries to include javascript inside iframe.

So the socket(s) in question are supplying content to the iframe?

It certainly seems as though Opera should be closing those connections if you click away from the page. But you might try explicitly destroying the iframes when leaving the page, something like:

window.onbeforeunload = function() {
    theIframe.parentNode.removeChild(theIframe);
    theIframe = undefined;
};

(I assume you have a reference to the iframe lying around somewhere.)

Edit: Or even navigating the iframe elsewhere first:

window.onbeforeunload = function() {
    theIframe.src = "about:blank";             // <== New bit
    theIframe.parentNode.removeChild(theIframe);
    theIframe = undefined;
};
流星番茄 2024-10-22 10:34:39

好吧,我想我们已经“工作”了......无需修改 javascript。我在 http-daemon 中为 opera 制定了具体规则,它用“403 Forbidden”回复旧的长轮询(问题是我之前为什么不尝试:P)。那些旧套接字上的简单 close() 只是让 Opera 重新打开连接。

可笑的是,即使我关闭浏览器上的选项卡,opera也不会关闭那些长轮询,我必须关闭整个opera进程。

Well, I think we got it "working".. Without modifying javascript. I made specific rule for opera in the http-daemon, that it replies to old long polls with "403 Forbidden" (Why didn't i try that before is the question :P). Simple close() on those old socket(s) just made opera reopen the connection.

It's ridiculous that opera wont close those long polls even if I close the tab on the browser, I have to close the whole opera process.

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