question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

client-side disconnect is not detected

See original GitHub issue
var 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:closed
  • Created 12 years ago
  • Reactions:23
  • Comments:61 (10 by maintainers)

github_iconTop GitHub Comments

7reactions
iamisticommented, Apr 28, 2016

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.

3reactions
pwhisenhuntcommented, Feb 5, 2014

I was able to fix this issue by adjusting the heartbeat timeout and heartbeat 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)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found