/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 nolast_seq query parameter on /v1/ws. On every reconnect:
- Tear down the existing socket and any in-memory delta queue.
- Re-hydrate via REST, in parallel:
- Open
wss://api.tradara.com/v1/wswith a fresh JWT. - Apply incoming
ws.user.v1envelopes on top of the hydrated state.
sequence / seq / offset is older than what the hydrated REST snapshot already reflects, drop it.
Suggested backoff
When not to reconnect
- HTTP
401on the upgrade — refresh the JWT first; tight retries will rate-limit the session. - HTTP
403on the upgrade — the credential is not a user JWT (e.g. a firm API key). Switch endpoints to/v1/firm-ws.

