Error Codes

Complete reference for WebSocket error codes and close codes.

Errors are reported in two ways depending on when they occur:

  • Before the connection is accepted: The server sends a WebSocket close frame with a numeric close code.
  • After the connection is accepted: The server sends a JSON error message over the open connection.

Close Codes

These are returned as part of the WebSocket close handshake. Your client will see them in the onclose event.

CodeMeaningWhen
4401UnauthorizedMissing, malformed, or invalid API key
1013Try Again LaterConnection limit exceeded for your account
1008Policy ViolationGeneric server-initiated close after sending an error message
1012Service RestartServer restarting; reconnect immediately

Handling Close Codes

ws.onclose = (event) => {
  switch (event.code) {
    case 4401:
      console.error("Invalid API key. Check your credentials.");
      break;
    case 1013:
      console.warn("Connection limit reached. Retrying in 5s...");
      setTimeout(reconnect, 5000);
      break;
    case 1012:
      console.info("Server restarting. Reconnecting...");
      reconnect();
      break;
    default:
      console.info(`Connection closed: ${event.code} ${event.reason}`);
      reconnect();
  }
};

Error Messages

These are sent as JSON messages over an open connection. The connection remains open -- you can fix the issue and retry.

{
  "op": "error",
  "code": "BAD_STREAM",
  "message": "Unknown stream 'foo'. Allowed: clusters"
}

Error Code Reference

CodeDescriptionResolution
BAD_JSONThe message you sent is not valid JSONCheck your JSON serialization
BAD_ARGSRequired fields are missing or the argument combination is invalidCheck the required fields for the operation
BAD_MODEThe mode field must be add or replaceUse "add" or "replace"
BAD_STREAMThe stream value is not recognizedUse a supported stream name (see Streams)
BAD_NETWORKThe network value is not recognizedUse a supported network ID (see Overview)
BAD_ADDRESSThe address is not a valid format for the specified networkCheck address format (e.g. base58 for Solana, hex for EVM)
CONN_LIMITYou've exceeded your plan's concurrent connection limitClose unused connections or upgrade your plan
TOPIC_LIMITYou've exceeded your plan's topic subscription limitUnsubscribe from topics you no longer need, or upgrade your plan
OP_UNKNOWNThe op value is not recognizedUse a valid operation: subscribe, unsubscribe, or ping