feathers-plus/feathers-offline-realtime

Socket.io disconnection facts

Closed this issue · 0 comments

You cannot be guaranteed a clean connection termination over TCP (https://en.wikipedia.org/wiki/Transmission_Control_Protocol#Connection_termination).

By default, a Socket.IO client will send a heartbeat to the server every 15 seconds (heartbeat interval), and if the server hasn't heard from the client in 20 seconds (heartbeat timeout) it will consider the client disconnected.

In mobile apps using a wireless network connection the heartbeat interval shouldn't be too short otherwise your battery will be drained fast (e.g. the Node.js default server-to-client heartbeat interval of ~25 seconds is not very good). https://developer.android.com/training/efficient-downloads/efficient-network-access.html#RadioStateMachine

When server calls socket.disconnect(), the reason given to disconnect handler is: io server disconnect. And when server stops, the reason is: transport close.