Connection Management
Best practices for maintaining reliable WebSocket connections.Optional Handshake Headers
Sockets that will be used to submit signed transactions via thepost method can opt into an alternative signature verifier on the WebSocket upgrade:
Semantics:
- Missing header: server uses the default raw canonical-binary verification path.
- Invalid value: ignored safely (falls back to default raw verification).
- Valid value: used only as an attempt-order hint. Signature validity still decides accept/reject.
- The header is never trusted for authentication by itself.
- Sockets posting transactions signed with the v0 Solana offchain envelope should set
x-bulk-sig-mode: offchain.
Subscription Management
Subscribe
Subscribe to one or multiple streams:Unsubscribe
Unsubscribe using the topic string:Reconnection Strategy
WebSocket connections can drop due to network issues. Always implement reconnection logic.Ping-Pong Keepalive (Required)
The server uses an explicit WebSocket ping/pong liveness check. You must respond to server pings with pongs or the connection will be closed.
Client recommendations:
- Respond immediately to ping frames with pong. Many WebSocket client libraries (e.g. Node.js
ws) do this automatically; if yours does not, handle thepingevent and send a pong. - Do not treat ping/pong as application messages -they are separate from
subscribe,post, and data messages. - If you are disconnected due to a missed pong, reconnect and resubscribe to your topics.
Rate Limits
The public mainnet endpoint permits 15 concurrent connections per client IP and 45 new connection attempts/minute per IP. Each connection has a 32-action/second trading budget with a 96-action burst. Use reconnect backoff and prefer reusing connections. See Public API Rate Limits for full HTTP/WS limits and rejection handling.Best Practices
Always implement reconnection logic
Always implement reconnection logic
Network issues are inevitable. Your application should automatically reconnect with exponential backoff.
Store subscriptions for resubscription
Store subscriptions for resubscription
After reconnecting, you must resubscribe to all channels. Store your subscription list.
Handle message ordering
Handle message ordering
Messages may arrive out of order during high load. Use timestamps and sequence numbers.
Respond to server ping with pong
Respond to server ping with pong
The server sends a ping every 30 seconds. If the client does not reply with a pong within 10 seconds, the server disconnects. Use a client that responds to ping (or handle it explicitly) and always implement reconnection.
Implement timeouts
Implement timeouts
If no application message is received for a long period, consider the connection stale and reconnect. Note: the server will already disconnect if pong is not sent within 10 seconds of a ping.
Use compression
Use compression
Enable per-message deflate for bandwidth savings on high-frequency streams.
Separate connections for trading
Separate connections for trading
Use one connection for market data and another for trading to avoid mixing concerns.