Error Handling & Reconnection

HTTP errors (during handshake)

If authentication or rate limiting fails, the server rejects the WebSocket upgrade with an HTTP error:

HTTP Code
Reason
Action

400

Malformed request

Fix your WebSocket client

401

Missing API key

Add X-API-Key header

403

Invalid, revoked, or expired key

Contact administrator for a new key

429

Rate limit or connection limit exceeded

Wait and retry with backoff

WebSocket close codes

Once connected, the server may close your connection with a close frame. The reason field tells you why:

Code
Reason
Meaning
Should reconnect?

1000

key_expired

Your API key's expiration date has passed

No -- get a new key

1000

key_revoked

Administrator revoked your key

No -- get a new key

1008

too_slow

You fell 10+ messages behind (lagging consumer)

Yes

1008

rate_limit_exceeded

You sent too many messages to the server (>30/min)

Yes -- stop sending messages

1009

frame_too_large

You sent a frame larger than 1 KB

Yes -- stop sending large frames

Exponential backoff

Decision logic

Heartbeat-based health check

Monitor heartbeats to detect silent disconnections:

circle-info

The server sends heartbeats every 30 seconds. If you receive nothing for 35 seconds, assume the connection is dead and reconnect.

Was this helpful?