JavaScript SDKAPI reference
Error codes
Every code a RealtimeError can carry, its HTTP status, whether it can be retried and what it means.
err.code is one of these numbers; Code.<Name> gives the number by name. err.retry tells you what may help:
retry | Meaning |
|---|---|
never | Retrying the same thing won't work; something must change first |
backoff | Try again later; honour retryAfterMs when set |
after-reauth | Try again with a new token |
reconnect | Reconnect, preferably to another node |
The SDK already retries backoff, after-reauth and reconnect errors where it can.
Request errors
| Code | Name | HTTP | Retry | Meaning |
|---|---|---|---|---|
| 100 | BadFrame | 400 | never | The node couldn't read a message from the client |
| 101 | InvalidArgument | 400 | never | A value is invalid, such as an option or an event name |
| 102 | UnsupportedVersion | 400 | never | The node doesn't speak this protocol version; update the SDK |
| 103 | UnsupportedFrame | 400 | never | The node doesn't support this request |
| 104 | UnsupportedFeature | 400 | never | The node doesn't support a feature the client asked for |
| 105 | FrameTooLarge | 413 | never | A message was over limits.maxFrameBytes |
| 106 | HelloRequired | 400 | never | The connection didn't authenticate first |
Authentication and permissions
| Code | Name | HTTP | Retry | Meaning |
|---|---|---|---|---|
| 200 | AuthRequired | 401 | after-reauth | No token; or your token endpoint or token function failed |
| 201 | AuthInvalid | 401 | never | The token can't be verified: unknown kid, wrong algorithm or segment, too long a lifetime. Also a revoked or expired publishable key, or anonymous connections turned off |
| 202 | AuthExpired | 401 | after-reauth | The token expired |
| 203 | Forbidden | 403 | never | The token doesn't allow this operation, or no topic rule allows it on this topic |
| 204 | Suspended | 403 | never | The segment is turned off, the workspace's subscription ended, or the publishable key is paused |
| 205 | ResumeRejected | 409 | never | A session resume was refused |
| 206 | Replaced | 409 | never | A newer connection of the same identity took this one's place |
Limits
| Code | Name | HTTP | Retry | Meaning |
|---|---|---|---|---|
| 300 | RateLimited | 429 | backoff | Too many publishes per second |
| 301 | QuotaExceeded | 429 | backoff | A segment limit was reached: connections, topics, subscriptions or messages |
| 302 | PayloadTooLarge | 413 | never | The payload is over limits.maxPayloadBytes |
| 303 | Backpressure | 503 | backoff | The client read too slowly; it reconnects and resumes without losing events |
Topics and publishing
| Code | Name | HTTP | Retry | Meaning |
|---|---|---|---|---|
| 400 | InvalidTopic | 400 | never | The topic name is invalid |
| 401 | ClassMismatch | 409 | never | The delivery type isn't allowed by the topic's rule |
| 402 | InvalidCursor | 400 | never | The cursor to resume from is invalid |
| 403 | IdempotencyConflict | 409 | never | The idempotency key was already used with different content |
| 404 | IdempotencyKeyRequired | 400 | never | A stream publish without an idempotency key (the SDK always adds one) |
Server
| Code | Name | HTTP | Retry | Meaning |
|---|---|---|---|---|
| 500 | Internal | 500 | backoff | An error on the node |
| 501 | Unavailable | 503 | backoff | The node can't serve the request right now |
| 502 | Draining | 503 | reconnect | The node is shutting down; the SDK reconnects and resumes |
| 503 | Overloaded | 503 | backoff | The node is busy |
| 504 | Timeout | 504 | backoff | No answer in time |
Raised by the SDK
These never come from the node; err.local is true.
| Code | Name | Retry | Meaning |
|---|---|---|---|
| 1000 | ClientClosed | never | The client was closed |
| 1001 | QueueFull | backoff | The offline queue is full (offlineQueue.maxSize) |
| 1002 | TransportUnavailable | never | No configured transport works here, e.g. no WebSocket or fetch |
| 1003 | Aborted | never | You aborted the operation |
| 1004 | NotConnected | backoff | The client is offline, or offlineQueue is false |
| 1005 | SegmentMismatch | never | The token is for another segment than connect({ segment }) |
| 1006 | IdentityChanged | never | updateToken() switched to another identity; subscriptions ended |
codeInfo(code) returns { name, httpStatus, retry, closesConnection } for any code.