开发者

Strophe sending double request on page unload

I have written an XMPP client with jQuery+Strophe. It all works well (1-on-1, presence, MUC, etc) and is contained within a jQuery-plugin. However, when the page unloads, it sends 2 final requests with the same rid. It only recently became a problem when I started working on session attachment.

Here is an example of the Firebug console:

Strophe sending double request on page unload

Here, I ju开发者_运维技巧st logged in and immediately refreshed the page. The first post you see is the initial presence stanza after the login. After that request, a new BOSH request has started to keep a connection open to the server. This request is aborted when I refresh the page. So far, everything goes as I expected.

However, after the aborted request, strophe sends yet another request with that exact same RID. The final request is sent from strophe for (I suppose) good manners and not relevant to the problem. However its response indicates that openfire (the XMPP server) killed the session in an attempt to protect the account.

I have looked at my code and cannot find any request made on my behalf. I'm fairly certain that strophe sends this request. However, it must come from something I did since my initial prototype did not have that problem (in fact, I often had to manually kill sessions on the admin panel because I forgot to close them via client).

Are there any known issues that I should check before I post the offending code?


I went back to the working prototype but discovered that it also had this very same bug. After a bit of testing, I found out that it only occurs after I immediately refreshed the page. If a request was made before refreshing the page, the bug does not happen. I informed the dev about this and made a hack to make it work until it is fixed on their side.

UPDATE:

I found out that this only happens with Firefox. Safari and even IE do it correctly (i.e. don't do the double post). So maybe it's Firefox that is behaving bad after all!

UPDATE 2:

I received a mail requesting the modifications I made. Here they are.

In strophe.js at around line 2566, change

sendFunc();

to

if (req.sends == 0) {
   sendFunc();
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜