Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

WebSocket client

Prefer the JavaScript or Rust SDK. This page is for reconnect behaviour and for people who read the wire.

Token on connect

MethodWhen
Authorization: Bearer AT_...Server-side clients
Sec-WebSocket-Protocol: llps.v1, at.AT_...Browsers (cannot set custom headers)

The server echoes only llps.v1. It never reflects the token.

Do not send JSON { "action": "subscribe" } frames. Subscribe, publish, and deliver use the SDK binary/text protocol (SUB:, OK:SUB:, binary publish/deliver frames). See WebSocket API.

Reconnect

Assume:

  • disconnects happen,
  • subscriptions are not durable,
  • there is a join window after resubscribe.

Recommended:

  • reconnect with exponential backoff and a max delay,
  • resend every subscription after a new socket,
  • wait for subscribe ack (or a short delay) before a critical first publish,
  • keep consumers idempotent.

The official SDKs reconnect and restore subscriptions. If you write your own client, you must do this yourself.

Common pitfalls

  • Origin: if the token sets allowed_ws_origin, the browser Origin must match.
  • Slow consumer: heavy work on the receive loop can get you disconnected.
  • Expired token: mint a new AT on the backend; do not keep a master token in the client.
  • HTTP /ping vs WS PING: /ping picks an edge. Application PING/PONG measures the live socket.

See Tokens and Troubleshooting.