Detect disconnects
Combine server ping/pong with client read timeouts; close past threshold, enter a reconnect state machine, and tag disconnect_reason.
Guide
Long-lived sockets face jitter and restarts. Detection, backoff, and state recovery decide terminal stability.
Combine server ping/pong with client read timeouts; close past threshold, enter a reconnect state machine, and tag disconnect_reason.
Backoff from 1s to a 30–60s cap with jitter. Alert on repeated failures—never spin forever.
On reconnect, resubscribe the full set and REST-calibrate last price to fill gaps.
Track uptime, reconnects, message gaps, and errors. Keep the last subscription list for failover.
See /guides/websocket-live-quotes, the Node.js guide, and /tools/ws-debugger.