Skip to main content
Connection lifecycle, authentication, heartbeat, and reconnection patterns for XOXNO WebSocket APIs.

Endpoints

The Relayer exposes two WebSocket endpoints: The /ws/stats endpoint operates independently. Connect to both when your application needs subscription-based topics alongside the network stats stream.

Connection lifecycle

  1. Connect: Open a WebSocket connection to either endpoint.
  2. Subscribe: Send subscribe actions to register for topics (/ws/stats subscribes automatically).
  3. Receive events: The server pushes JSON events for each subscribed topic.
  4. Send actions: Submit broadcast or relay actions to process transactions.
  5. Unsubscribe: Remove subscriptions you no longer need.
  6. Disconnect: Close the connection cleanly.

Authentication

Neither WebSocket endpoint requires authentication. The server treats all connections equally.

Message format

All messages use JSON encoding. Text frames are the standard transport. The server also accepts binary frames for legacy JSON payloads and protobuf batch broadcast.
  • Maximum message size: 4 MB
  • Encoding: UTF-8 JSON
Client-to-server messages include an action field. Server-to-client messages include either a type field (for events) or an action + status field (for action responses).

Heartbeat

The server sends a WebSocket ping frame every 30 seconds. Your client must respond with a pong frame. Most WebSocket libraries handle this automatically. If the server receives no pong within the next ping interval, it closes the connection.

Connection limits

Sending more than 64 control messages within a 5-second window triggers a rate-limit error. Both subscribe and unsubscribe actions count toward this limit.

Reconnection strategy

Use exponential backoff with a cap: After reconnecting, re-subscribe to all topics. The server does not persist subscriptions across connections.

Connection examples

Read-only stats stream

The /ws/stats endpoint requires no subscribe action. Data arrives as soon as you connect:

subscribe

Subscribe to real-time topics: gas stats, network stats, account deltas, and tx status.

broadcast

Submit pre-signed transactions for P2P broadcast via WebSocket.

gasStats

Per-shard gas price and PPU statistics, every 50ms.

networkStats

Full network snapshot: TPS, blocks, mempool, validators, health.