Skip to main content
/v1/ws is a long-lived connection. Treat every reconnect as a hard re-sync — the server does not replay events you missed while disconnected.

Backpressure / slow consumer

The server emits WebSocket ping frames every ~20 seconds. If the client cannot keep up with delivery rate (typically: blocking the read loop on synchronous work), the server disconnects under its slow-consumer policy rather than buffering unbounded memory. To stay ahead of delivery:
  • Move event handling off the read loop onto a queue / worker.
  • Drop frames that no longer affect UI (e.g. position updates older than the latest already applied).
  • Avoid synchronous HTTP or DB work in the WebSocket handler.

Reconnect loop

There is no last_seq query parameter on /v1/ws. On every reconnect:
  1. Tear down the existing socket and any in-memory delta queue.
  2. Re-hydrate via REST, in parallel:
  3. Open wss://api.tradara.com/v1/ws with a fresh JWT.
  4. Apply incoming ws.user.v1 envelopes on top of the hydrated state.
If an envelope’s inner sequence / seq / offset is older than what the hydrated REST snapshot already reflects, drop it.

Suggested backoff

When not to reconnect

  • HTTP 401 on the upgrade — refresh the JWT first; tight retries will rate-limit the session.
  • HTTP 403 on the upgrade — the credential is not a user JWT (e.g. a firm API key). Switch endpoints to /v1/firm-ws.