Ping
Send aping frame at least every 5 minutes.
ping in 5 minutes is closed without warning.
This is an application-level frame, not a WebSocket protocol ping. Many client
libraries send protocol-level pings automatically; those do not satisfy this
requirement. Send the JSON frame.
Reconnecting
A server-initiated close is routine. Reconnect and resubscribe. The server does not send a specific close code on these closes, so most client libraries will report 1005 (“no status received”). Do not treat 1005 as an error condition worth alerting on; treat it as a signal to reconnect. On reconnect you must redo both halves of your session:1
Re-authenticate
Send
authenticate again if you want your
private stream. Authentication does not survive a reconnect.2
Resubscribe
Send your full
subscribe target set again.
Subscriptions do not survive a reconnect either.3
Backfill the gap
Reload current state over REST for anything you track cumulatively —
positions, open orders, the order book — because updates that occurred
while you were disconnected are not replayed.