Skip to content

Commit 2817b6d

Browse files
Mlaz-coderootPaperclip-Paperclip
authored
docs(streaming): document WS close code 1006 as RFC-reserved client-side code (#200)
Add code 1006 to the close code tables in both the WebSocket streaming guide and the WebSocket API reference, with a Callout explaining that it is never transmitted over the wire — the client WebSocket library generates it locally on abnormal TCP teardown (network loss, process kill). Developers commonly mistake it for a server-sent code; the callout surfaces this before they waste time debugging the server side. Co-authored-by: root <root@api-dev.hs.chocopancake.com> Co-authored-by: Paperclip <noreply@paperclip.ing>
1 parent e6814ea commit 2817b6d

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

content/en/api-reference/websocket.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,10 +590,15 @@ WebSocket frames may also carry the HTTP-style `invalid_api_key`, `tier_restrict
590590
| Code | Meaning | Resolution |
591591
|------|---------|------------|
592592
| `1000` | Normal close | Client or server initiated clean close |
593+
| `1006` | Abnormal closure (client-side) | Network drop or process kill — always reconnect |
593594
| `4001` | Authentication failure | Check your API key |
594595
| `4003` | No streaming access | Add WebSocket add-on ($99/mo) or upgrade to Enterprise |
595596
| `4029` | Stream limit exceeded | Close unused connections (default: 1 per key; newer connection wins) |
596597

598+
<Callout type="warning">
599+
**Code 1006 is RFC 6455 reserved and is never transmitted over the wire.** Your WebSocket library generates it locally when the TCP connection is lost without a proper closing handshake (network failure, process kill, OS-level timeout). The server did not send it. Always reconnect on 1006.
600+
</Callout>
601+
597602
## Sequence Numbers
598603

599604
Every server message includes a `seq` field — a per-connection integer that increments with each message. The `connected` message also includes `global_seq`, a server-wide event counter.

content/en/streaming/websocket.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,15 @@ The server keeps a 2-minute replay buffer. Pass `resume=true&from_seq=N` on reco
155155
| Code | Meaning | Action |
156156
|------|---------|--------|
157157
| `1000` | Normal close | No action needed |
158+
| `1006` | Abnormal closure (client-side) | Network drop — always reconnect |
158159
| `4001` | Bad or missing API key | Fix your API key |
159160
| `4003` | No streaming access | Purchase WebSocket add-on |
160161
| `4029` | Too many connections | Close unused connections first |
161162

163+
<Callout type="warning">
164+
**Code 1006 is RFC 6455 reserved and never sent by the server.** Your WebSocket library generates it locally when the TCP connection drops without a closing handshake (network failure, process kill). Always reconnect when you see it — the example below already does this correctly by only skipping reconnect on `1000`.
165+
</Callout>
166+
162167
## Full API Reference
163168

164169
For complete documentation including all message schemas, error handling, and multi-language examples, see the [WebSocket API Reference](/en/api-reference/websocket).

0 commit comments

Comments
 (0)