wtf( )unctionsystem design, drawn
← all problemsWebSocketsMedium

Connections that died quietly every sixty seconds

The sockets are long-lived and mostly quiet. After roughly a minute of no traffic they stop working, and neither end logs an error — because neither end noticed. Something in the middle closed the connection.

An intermediary's idle timer counts any traffic, and a socket that is quiet is idle by that definition. Something has to keep it warm, and something separate has to notice when the peer is gone.

Keep the connection off the idle timer, and give both ends a way to detect a dead peer.
Components — tap one, then tap a slot on the diagram
!Sockets drop after about a minute of quiet. No error on either side — the client just stops receiving.

Outside every boundary: Load balancer (idle timeout 60s), No messages for 90s (a normal afternoon), Client, Socket server (FAILED: peer already gone), an empty slot for the shorter than any idle timeout, an empty slot for the what proves the peer is alive Connections: Client holds an open connection to Load balancer (step 1) Load balancer holds an open connection to Socket server (step 2) No messages for 90s controls Load balancer — counts as idle shorter than any idle timeout controls Load balancer — resets the timer (step 3) what proves the peer is alive controls Socket server — no reply, close it (step 4)

Load balanceridle timeout 60s
No messages for 90sa normal afternoon
Client
Socket serverpeer already gone