The mechanism

Either side sends a Ping frame (0x9). Recipient must reply with Pong (0xA), echoing the payload. Missing pong = connection considered dead.

Advertisement

Interval choice

30-60 seconds is standard. Under 15 = wasted bandwidth on mobile. Over 120 = slow to detect broken connections.

Advertisement

Which side sends

Historically server. But client-initiated pings work too, and detect network partitions from the client side. Bidirectional pings + timeout each side is safest.