-
Notifications
You must be signed in to change notification settings - Fork 0
Codecs
GitHub Actions edited this page Apr 23, 2026
·
1 revision
The WebSocket wire format is negotiated at handshake time via the Sec-WebSocket-Protocol header.
| Protocol header value | Frame type | Notes |
|---|---|---|
(none) or restnio.json
|
Text | Default. Envelopes are UTF-8 JSON. |
restnio.msgpack |
Binary | MessagePack envelopes. Requires optional dep @msgpack/msgpack. |
The server negotiates automatically — no extra server-side code required.
Clients connect without a subprotocol (or explicitly request restnio.json). All message envelopes are plain JSON text frames:
{ "path": "/chat", "params": { "text": "hello" }, "token": "<jwt>" }Install the optional dependency:
npm install @msgpack/msgpackClients connect with the restnio.msgpack subprotocol. Envelopes are binary MessagePack frames. The server uses a first-byte sniff to distinguish codec envelopes from raw binary data.
setBinRoute()always takes priority over the codec sniff. See Binary Routing.
The codec registry is available for inspection or extension:
RestNio.codecs // inspect registered codecs or add custom onesGetting started
HTTP
WebSocket
Server features
Reference