Why heartbeat
Middleboxes drop idle TCP sessions; periodic ping keeps the channel warm and surfaces disconnects early.
Client implementation
On read timeout, send ping or close; reset timers after pong.
Works with subscribe
After reconnect, re-send subscribe — servers do not remember prior symbol lists.
Reconnect link
Heartbeat timeout should enter reconnect—not hang silently; always resubscribe after reconnect.
Practice
See reconnect guide and WS debugger.