maxpowel / jQuery-XMPP-plugin

Javascript library for the XMMP protocol
http://plugins.jquery.com/project/xmpp-lib
163 stars 50 forks source link

Timeout Issue #9

Closed baliganikhil closed 12 years ago

baliganikhil commented 12 years ago

Hi, I tried your example code and everything works great. I then kept your code open on one computer and used Pidgin on the other - And the communication was working fine. But then, after a brief while, I saw that the user on the browser appeared offline in Pidgin, as in, the connection terminated because of a timeout of some sorts (I am assuming).

Could you please let me know if it is possible to set a value for the time out? Or if it can be extended? The timeout seems very short

shaundon commented 12 years ago

I have the same issue.

bluemoz commented 12 years ago

I've too. it doesn't seems a timeout issue. How could be managed a reconnect call?

shaundon commented 12 years ago

Maybe if there was a way to define a keep-alive packet..

shaundon commented 12 years ago

I've looked into this a little more. When my page loads, the spinning 'loading' icon carries on displaying once the page is loaded. This lasts for exactly 60 seconds, then stops. After that, the connection to the XMPP server is broken after around another 30 seconds.

As it seems to last for exactly 60 seconds, I think it must be by design..

shaundon commented 12 years ago

Ok, got it :) On line 60ish of jquery.xmpp.js:

var msg = "<body rid='"+this.rid+"' xmlns='http://jabber.org/protocol/httpbind' to='"+domain+"' xml:lang='en' wait='60' hold='1' content='text/xml; charset=utf-8' ver='1.6' xmpp:version='1.0' xmlns:xmpp='urn:xmpp:xbosh'/>";

You can change wait='60' to however long you want the connection to stay alive for.

This does however mean that the connection stays open for X seconds after you close the browser.

werdnum commented 12 years ago

I have a proper fix in #11.

maxpowel commented 12 years ago

Perhaps would be fine that we can specify the timeout as parameter (and use 60 as default)?

werdnum commented 12 years ago

EDIT: Never mind, I see you did actually merge my bug fix, so obviously you're just making the same point I am that a configurable timeout would be useful.

Original comment is below

BOSH connections are not supposed to time out because of 60 seconds' inactivity. That's the whole point of them.

The "wait" time is the maximum time that a client should wait for a response. It is not the inactivity timeout. See the spec.

So while you might specify the timeout as a parameter (I think this is a good idea), it does not fix the underlying issue, which is that this module does not correctly implement the XEP-0124 spec unless it sends another poll request when it receives an empty <body/> response from the server.

maxpowel commented 12 years ago

EDIT: Now you can choose the wait and inactivity time. If answer delay is more than wait time is caused a network failure and the event onError and onDisconnect are triggered. Check this issue to get more details https://github.com/maxpowel/jQuery-XMPP-plugin/issues/8


It looks like that your fix solves the problem, thank you! Please test it and notice if this problem persists for you or not (to close the issue or continue working on it)