开发者

Opera leaves long polling socket(s) open

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


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;
};


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜