Symptoms
- The socket closes, or goes quiet, and your client stops receiving data.
- After a reconnect, nothing arrives because the client never re-subscribed.
- An
errormessage witherror_codeslow_consumerarrives, and then a subscription stops sending or the socket closes. - A replay refuses
replay.seek, or ignoresspeed. - A Free account receives no live data after its first 30 days.
Match the symptom to the cause
Reconnect and restore subscriptions
The server sends a ping frame every 30 seconds. A connection with active subscriptions can be closed after 60 seconds without activity, and one with no subscriptions after 300 seconds. Keep the subscriptions your client wants in one list, and send them again on every new socket. This Node.js client tracks Hyperliquid BTC trades, reconnects with capped exponential backoff and jitter, and records the newest trade time so it knows what it missed:subscribed again with the time of the last trade it saw. Stop after a retry budget in production instead of reconnecting forever, and log the close code, retry count, and restored subscriptions. Keep-alive has the full sequence.
Handle lag notices
A connection that reads too slowly receives anerror message with error_code slow_consumer. On Lighter, a connection that falls behind lighter_trades or the Lighter stats channels receives a notice counting the messages it missed, for example Dropped ~N live lighter_trades messages for BTC. Persistent lag stops that subscription until the client re-subscribes. A socket that stays behind across many sends on any channel is closed after a final slow_consumer message. What to do depends on the channel:
Reduce the subscription set or move heavy work off the message callback before you re-subscribe, or the same lag returns.
Fill the interval you missed
Choose by what the job needs:- REST history returns the rows of a bounded window, ordered after retrieval. Request the missed trades from the last time you saw to now, page with
meta.next_cursor, and drop rows you already hold. Hyperliquid trades return one row per side of each trade, so dedupe ontrade_idandside. Troubleshoot pagination has the loop. - Standard replay sends stored events in order, starting at the
startyou give.endis optional and defaults to now;replay_startedreports the effective window. The replay ends withreplay_completedand does not follow new events, so keep the live subscription for anything after it. A live subscription and a replay can run on the same connection; a second replay while one is running is refused withconflict.
meta.finalized_through, so the newest Lighter trades come from /v1/lighter/trades/{symbol}/recent instead.
L4 and full-depth replay rules
L4 replay (l4_diffs, l4_orders and the spot_, hip3_ and hip4_ variants) and full-depth replay (orderbook_full, hip3_orderbook_full) follow different rules from standard replay:
- The server anchors the run to the latest checkpoint at or before
startand opens with anl4_snapshot. l4_batchmessages follow: up to 5,000 order events per batch in block order on the L4 channels, and price-level changes in 100 ms windows of event time on the full-depth channels.- The stream can include updates before your
start, to roll the checkpoint forward. Apply them before you score the study window. speedis ignored, and each run is single-channel.replay.seekis refused withunsupported_for_venue:replay.seek is not supported for L4 channels (restart the replay at the desired start instead). Send a newreplaywith the newstart.
Verify the fix
- Every tracked subscription has a
subscribedacknowledgement on the current socket. - The filled interval runs from the last delivered time to the first live message, with no duplicate keys.
- A replay ended with
replay_completed, and anygap_detectedevent is recorded with the output.
Related
- WebSocket connection: authentication and connection state
- WebSocket replay: replay commands, events, and run manifests
- Lighter channels: every Lighter notice and stop message
- WebSocket limits: subscriptions, connections, and standard replay speed by plan