websocket-proxy
Sets the largest WebSocket message, per direction, a ws or wss upstream may exchange.
websocket-proxyPriority 511What it does
websocket-proxy sets the largest single WebSocket message the gateway takes in each direction. Client message limit holds a message from the client, and Upstream message limit one from the backend. Left unset, a limit of 65,535 bytes applies to each.
It acts on a route whose upstream speaks WebSocket, with the scheme ws or wss, and the route itself needs Websocket on.
When to use it
- A live order-tracking feed in the mobile app, where the backend pushes snapshots larger than 65,535 bytes.
- A support chat for partners, where a client message never needs more than
16384bytes and a larger one is a mistake or misuse. - Clients that send small commands while the backend answers with large updates, so each direction needs a limit of its own.
Not for the size of an ordinary HTTP request body — see client-control (Controls the client request body size) or how many connections one client holds open — see limit-conn (Limits concurrent connections per key).
Set it up
Limit the size of a WebSocket message in each direction
Both values sit below the 65,535 bytes that apply when nothing is set; the route needs Websocket on and a ws or wss upstream.
Set Client message limit to 16384 and set Upstream message limit to 32768.
{
"client_max_payload_len": 16384,
"upstream_max_payload_len": 32768
}
Things to know
- The limits apply to the messages a ws or wss upstream exchanges.
- A route lets a request upgrade its connection to WebSocket only with Websocket on.
- Client message limit — A limit of
0is refused when you save. - AdviceSet each limit a little above the largest message your clients and your backend send in normal use.
Settings
The fields as the console shows them, section by section.
client_max_payload_lenintegerThe largest single message, in bytes, accepted from the client; unset, the library limit of 65,535 applies.
upstream_max_payload_lenintegerThe largest single message, in bytes, accepted from the target; unset, the library limit of 65,535 applies.