client-side disconnect is not detected
See original GitHub issuevar socketio = io.connect(socketServer,
{rememberTransport: false,
'reconnect': true,
'reconnection delay': 500,
'max reconnection attempts': 10,
'secure': true});
socketio.on('disconnect', function() {
alert('client socketio disconnect!')
});
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.
Issue Analytics
- State:
- Created 12 years ago
- Reactions:23
- Comments:61 (10 by maintainers)
Top Results From Across the Web
Detect if client side is disconnected from network with socket ...
I need to detect if client side is disconnected from internet and fire socket.disconnect() manually/automatically. I have searched but cant ...
Read more >The Socket instance (client-side)
This event is fired upon disconnection. ... In the first two cases (explicit disconnection), the client will not try to reconnect and you...
Read more >After disconnecting client, reconnecting is not working.
When the client disconnects for the first time everything works fine but when it again connects to the host, These three errors are...
Read more >Detect Server disconnect using TTCPClient component
Hi I am having a problem in detecting Server closes the connection using the TTCPClient component. In the server side, i am using...
Read more >RDS client disconnected codes and reasons - - Rackspace
Your computer can't connect to the remote computer due to one of the following reasons: 1) The requested Remote Desktop Gateway server address...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Please re-open this ticket, since it’s not yet fixed! I’was looking at the file: https://github.com/socketio/socket.io-client/blob/master/lib/manager.js to figure out if there is any option for that, and I found
timeout
which is 20 second by default. But when I’ve tried to change it to 4 sec, it just didn’t work at all.I was able to fix this issue by adjusting the
heartbeat timeout
andheartbeat interval
settings on the server, which I believe dictates the client side heartbeat. For example, if you’d like the client to trigger a disconnect after it does two heartbeats every 4 seconds and doesn’t get a response then you would configure like the following.io.set('heartbeat timeout', 10) io.set('heartbeat interval', 4)