Viewing: Errors

Real-time WebSocket - Errors

Handle websocket failures with a unified error envelope. Treat close code as class and latest `error.code/details` as the action signal.

WebSocket Error Codes

WS_INTERNAL_ERROR4000

An internal connection failure interrupted setup.

Action: Retry with capped exponential backoff and jitter.

WS_AUTH_OR_ACCESS4401 / 4403MARKET_DATA_ENTITLEMENT_*

Account access or entitlement issue blocks streaming access.

Action: 4401 means fix API key auth, 4403 means fix account/plan entitlement state. Do not auto-reconnect.

WS_RATE_LIMIT4429DEPTH_WS_*_LIMIT / *_RATE_LIMITED

Connection, subscription, or action throttles were exceeded.

Action: Retry with backoff + jitter and honor `retry_after_seconds` from latest error details when present.

WS_INVALID_REQUESTINVALID_JSON / UNKNOWN_ACTION / SYMBOL_REQUIRED and lowercase variants

Malformed payload or unsupported action.

Action: Codes are channel-specific and case-sensitive. Fix the payload and retry the action; the socket normally remains open.

Multi-connection guardrails

  • Open sockets with a 200-400ms stagger instead of starting all at once.
  • Queue reconnect attempts globally per API key.
  • Avoid synchronized reconnect storms around market open.

Off-hours connections

You may keep WebSocket connections open outside market hours. SAHMK does not intentionally disconnect clients at market close. Continue sending a ping every 30 seconds, reconnect with capped exponential backoff and jitter when necessary, and restore subscriptions after every reconnect. Market events may be absent while the market is inactive.

Error Envelope

json
{
  "type": "error",
  "code": "ERROR_CODE",
  "message": "Human-readable message",
  "details": {}
}

Last updated on