Does Socket.IO connection state recovery survive a server restart, or do I need external persistence?
0 reputation · 28 Jan 2021, 05:58 UTC
0 reputation · 28 Jan 2021, 05:58 UTC
I want clients that briefly lose connectivity to receive the events they missed and keep their room memberships after reconnecting, even if the Socket.IO server process restarts during the outage.
Assume Socket.IO v4.6+ on both server and client, with connectionStateRecovery enabled and a configured maxDisconnectionDuration. As documented, recovery state—session identity, rooms, and missed packets—is held in server memory by default. That implies a restart or crash inside the disconnection window discards it, and the reconnecting client is treated as brand new. In a multi-node setup I also understand room and recovery state is per node unless a compatible adapter (e.g., Redis) is configured, though I have not verified how that interacts with recovery specifically.
The documented alternative for durability is building at-least-once delivery myself using acknowledgements with timeouts (socket.timeout(ms).emit) plus client-side buffering or a custom event queue.
A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.