Start with a known-good subscription
slotSubscribe fires every slot, about five times a second, so it shows almost immediately whether the connection itself works. Install wscat with npm install -g wscat, then:
Connection refused
Authentication happens during the WebSocket handshake. When it fails, the server answers the upgrade request with a normal HTTP error and a JSON body instead of switching protocols. Many WebSocket libraries only report “unexpected server response: 403” and drop the body, so check the handshake with curl to see the real reason:HTTP/1.1 101 Switching Protocols means authentication passed. Otherwise:
Other things to check:
- The host resolves. WebSocket runs on the RPC hosts:
wss://{region}.rpc.orbitflare.com. There is nowss://mainnet.rpc...orwss://global.rpc...host. See Infrastructure for the list. - The URL uses
wss://. Passing anhttps://URL to a WebSocket client fails before the request reaches OrbitFlare. - TypeScript only:
Cannot find package 'ws'means the optional peer dependency is missing. Runnpm install ws.
Connected but no updates
The server confirms every subscription with a numeric ID. If you never get one, the request was rejected, and the reply says why:- The account is not changing.
accountSubscribeonly fires when the account’s data or lamports change. Test with an account you know is busy, such asSysvarC1ock11111111111111111111111111111111, which changes every slot. - The filter matches nothing. For
programSubscribeandlogsSubscribe, an address that never appears in a transaction produces no events. Check the address on an explorer first. - The signature is old.
signatureSubscribeonly knows about recent transactions. For anything older than a few minutes, callgetSignatureStatuseswithsearchTransactionHistory: trueinstead. See Wait for a transaction to confirm.
Connections that drop
Idle connections close without warning
A connection with no traffic is eventually dropped, and it is closed abruptly rather than with a close frame, so your client sees code1006 with an empty reason. Keep it alive by sending WebSocket ping frames every 20 to 30 seconds:
Subscriptions are gone after a reconnect
Subscriptions belong to a connection. When it drops, they are gone, and a new connection starts with none. Keep a list of what you subscribed to and send those requests again after reconnecting. Note that the subscription IDs change. The SDKs track subscriptions and resubscribe automatically. Yoursub.next() loop keeps running across reconnects.
Unsubscribing fails
Invalid subscription id. means that ID does not exist on this connection. Usually the connection was replaced and the ID belongs to the old one. It is safe to ignore.