1

How does the server know when the client suddenly dies/disconnects due to network/power failure in SocketIO. Since the client wont have any chance to emit a disconnect event to the server... is there any way to solve this issue?

Prata
  • 1,250
  • 2
  • 16
  • 31
  • socket.io times out and will raise a disconnect event: http://stackoverflow.com/questions/26025628/node-js-socket-io-1-0-timeout-event – slebetman Jan 29 '16 at 17:44

1 Answers1

2

Socket.io has an internal keep alive mechanism. If a client disconnects abruptly, the server doesn't know about it immediately. Instead, when the next keep alive mechanism event will fire and no response will arrive within the time limit, the server will fire disconnect event for that client. The time it takes for the server to detect a client disconnected is affected from the keep alive polling intervals and the timeout limit.

You can change those values using 'pingInterval' and 'pingTimeout', which will change the way engine.io is configured.

Kuf
  • 17,318
  • 6
  • 67
  • 91
  • yeah, thanks alot for the answer. I had this issue first with the **websocket** on which the **socketIO** is built on top of. I thought if there are any other ways than heartbeat mechanism but thanks... your answer helped a lot :) – Prata Jan 30 '16 at 04:33