Socket.io delay on triggering a disconnect event?

I have a socket.io client connected to node.js. If I kill node.js on the command line, the client immediately freezes (i.e., the connection stops), but there is a delay of 20 seconds before the disconnect event. Is this design behavior? Is there a configuration option to reduce the delay when triggering a trip event?

It looks like this behavior has changed in the relatively recent (last 6 months) socket.io update. Before reconnect functionality was built into socket.io, I implemented my own reconnection logic using the disconnect event handler, and the disconnect event was triggered almost instantly when the connection to the server stopped.

+5
source share
2 answers
+6
source

I think this is more of a design template. The client may assume that the server is "temporarily" unavailable (network traffic, etc.) and, in essence, will try to reach it ... until the client expires.

I am sending to the server directly from the client, disconnecting (socket.disconnect ()), and I am not getting this problem.

+2
source

All Articles