-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Websocket not closed on disconnect, _doDisconnect called multiple times #4
Comments
Could you test if this branch https://github.com/Gordin/strophejs/tree/disconnect-fix fixes the problem for you? |
Heyup, fraid not, it appears to be moving beyond the disconnecting stage now but it is still firing multiple _doDisconnect calls that are breaking the reconnecting, here is my console output: chat.getServerList().getServer(1).disconnect(); And without reconnection code: Server (1): Disconnect called core.js:662 It seems to call _doDisconnect three times =/ P.s. thanks for being so quick to respond to these issues :) |
Could you give me some code to replicate this? I've tried to do it myself but in my tests the _doDisconnect in core and websockts is only called once and also reconnecting works for me. |
//On connection disconnected
As far as I can tell it's no longer doing multiple disconnect attempts (using latest code) but if you reconnect in the above manner I still get the websocket error, as if it's been force closed. Chances are I'll put in a brief timeout between connection attempts which seems to fix the problem but the above code still results in this: Server (1): Disconnect called core.js:685 However, just tested this on Firefox and received no errors it might be browser specific. I've been using Chrome (v 27.0.1453.116) on Windows 7 for development. |
I actually never tried the reset thing much, but I just tested with if (status === Strophe.Status.DISCONNECTED) {
Peek.connection.reset();
return Peek.connection.connect("gordin@localhost", "gordin"); which should have the least time in between reset and connect on both chrome and firefox and I'm not getting any errors and the connection is established as it should. (I'm using Chrome 28 though, that's probably not it but maybe they fixed some WebSocket handling in 28?) |
When a Websocket connection is opened, then disconnected, after it sends the end of stream messages and so on it seems to just stop and not close the socket, this makes the _doDisconnectTimeout method fire. However after that is done it also fires multiple _doDisconnect calls that interferes with reconnection.
My code attempts to connect to the server again if the connection is disconnected, however after it starts attempting to connect the _doDisconnect is fired again which causes a socket exception complaining that you can't shut the socket before it's been opened. I have pasted my console output below and removed urls/commented where needed:
Server (1): Disconnect called
Server (1): Connection destablished callback
Server (1): Disconnecting...
Strophe: Disconnect was called because: Disconnect method was called.
LONG PAUSE
Strophe: _onDisconnectTimeout was called
Strophe: _doDisconnect was called
Server (1): Disconnected from server.
Server (1): Connect called
Server (1): Connecting to MY_WS_URL...
Strophe: _doDisconnect was called
EXCEPTION START
WebSocket connection to 'MY_WS_URL' failed: WebSocket is closed before the connection is established. /pages/chat/js/lib/strophejs-websocket/strophe.js
Strophe.Websocket._doDisconnect strophe.js:4683
Strophe.Connection._doDisconnect strophe.js:2843
Strophe.Websocket._onClose strophe.js:4706
EXCEPTION END
Strophe: _doDisconnect was called
The text was updated successfully, but these errors were encountered: