-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
client-side disconnect is not detected #635
Comments
Hello, Did you find a solution to this ? |
I'm curious about this too. I'm having trouble getting disconnect events to fire reliably regardless of the situation, but this may be my own fault. |
+1 |
I found a pseudo-solution where I do io.emit('ping') every 30 seconds or so on the front-end. If there has been a disconnect, this ends up triggering an automatic reconnect. |
Here is my test, all on Mac using FF 10.0.2, Chrome 17.0.963.79 and Safari 5.1.2 (6534.52.7) The client app listens on all available io events.. connect, connecting, connect_failed, disconnect, reconnecting, reconnect and reconnect_failed and logs out to console the situation.. i am connect on all browser via websockets now i turn off wifi => i send a ping from FF and Chrome to provoke a disconnect event => i turn on wifi again => i send messages between the clients => |
+1 |
1 similar comment
+1 |
similar situation here. I've 2 device ipod touch (iOS 4.2.1) + galaxy note. galaxy note can always detect the disconnection of ipod touch while the ipod cannot. Seems safari block incoming data via websocket=[ |
Still having this issue. I read some posts describing the same issue one year ago. I think i have to work around it myself? ... |
+1 |
2 similar comments
+1 |
+1 |
Just a small heads up, if you wrap socket.io with primus this issue would be resolved. It uses a combination of ping packets and online/offline events to determine these connections issues. |
I was able to fix this issue by adjusting the
|
+1 |
2 years and no solution at all ? Why Safari is the only browser that could detect the disconnect ? FF and Chrome do not follow the standards ?? |
+1 |
Thanks @pwhisenhunt |
@pwhisenhunt but for some cases decreasing heartbeat causing another problem. |
Yep, that's correct. Thanks for bringing that up! Sorry I must have forgotten that in my previous comment. I'm curious if this is fixed in 1.0? Please pardon any misspellings, this message was sent from my iPhone.
|
Any solution to "disconnect event not getting fired" yet? or am I missing something. As the last solution suggested by @pwhisenhunt is not so reliable. |
We are having this same issue on 1.3.6 version of socket.io. The node server in our case is not getting the disconnect event from client when wireless is shut off or laptop is closed. |
+1 |
I am experiencing this same issue, using version 1.4.3. Why is the issue closed? |
Please re-open this ticket, since it's not yet fixed! |
Have the same issue. Could be reproduced in chrome without actual internet disconnection. Just open |
any news that can work? |
|
I just tested with the chat example (socket.io Websocket gets established: 25s being the default value for Can anyone confirm/infirm that behaviour? Also, if the server gets killed, I think that the disconnect event would be fired immediately since the underlying TCP connection is closed. |
I can confirm this behavior: disconnect gets fired on both server and client if a network cable is unplugged. However, there is also the case where the client gets disconnected from the server without any events being fired. The below screenshots are from a client that is no longer emitting to the server. No disconnect events have been fired (either on the client or on the server). Note that the client still seems to be receiving pongs from the server: |
Hmm, I don't understand, how do you know the client gets disconnected then? |
Yeah, "disconnected" is probably not the right wording. The issue is that the client stops emitting to the server, although it is still receiving pongs from it. In the last screenshot I posted, socket.emit should have been called in between the ping pong events, but somehow it hasn't. |
So, if I understand correctly, the socket is still emitting pings/getting pongs, but Can you reproduce easily? Is it linked to a given browser? Ref: https://github.com/socketio/socket.io-client/blob/1.7.2/lib/socket.js#L155 if (this.connected) {
this.packet(packet);
} else {
this.sendBuffer.push(packet);
} But the only way the Socket.prototype.onclose = function (reason) {
debug('close (%s)', reason);
this.connected = false;
this.disconnected = true;
delete this.id;
this.emit('disconnect', reason);
}; So it shouldn't be discarded here, since you didn't get the Socket.prototype.sendPacket = function (type, data, options, fn) {
//...
if ('closing' === this.readyState || 'closed' === this.readyState) {
return;
} The |
Yes, that's it. Will try to find a way to reproduce. |
@darrachequesne Turns out my own code was blocking calls to socket.emit. Apologies for having wasted your time. My issue was not the same as the issue of this thread, and certainly not an issue with socket.io. |
@creole great, thanks! To all others who +1'ed, has my comment #635 (comment) fixed (or at least explained) your issue? In any case, maybe a smaller default value for |
Changing default setting so much can lead to unexpected behavior in some implementations, but I agree dropping |
It might be useful |
Experiencing this problem as well.. Changing ping interval does not seem reliable enough in production |
As long as the bug will not be resolved shortly and a final purpose of what we need is to indicate if user has left, we can extend our socket object by using middleware. Basically, we need to extend socket object with a user and a room the user is currently in and after user got disconnected we can use that properly as we need. Full code is available at: https://github.com/abitlog/retube/blob/master/server/utils/socket.js
|
@abitlog I may be missing something here, but your use case is not related to the current issue, right? Please take a look at the disconnecting event. |
@darrachequesne I investigated the issue and it seems all events are working fine. It's just in Chrome for mac (didn't notice this in windows version) taking long time (approx 1 min) to trigger disconnect. I tried of course |
@KamWis which value are you using for |
I just went through all of my connection settings again and I must have had a typo somewhere. When I set |
I guess the issue can be closed now? |
Yep, I believe so. Looks like everything is working as expected. |
I can detect disconnect event but it took time at least 8-10 seconds. |
@Royalone-mobile please update the |
I have solved this problem. |
Hi guys, Any luck with this? I am also facing the same issue. |
Got it working smoothly on local server. Socket io fire disconnect event immediately each client disconnected. But dunno why it didn't same on real server |
on mobile device working fine, but facing same problem on desktop/laptop. |
The alert shows up if I take down the Node server, but not if I turn off my wireless, or close my laptop and re-open it later. The connection is lost though. Is there a better way to detect disconnect on the client side? This is with the WebSockets transport.
The text was updated successfully, but these errors were encountered: