# uvicorn websocket defaults: ws_max_size 16 MiB, close code 1009 when exceeded; ping 20 s / timeout 20 s closes with 1011

- Source: https://chatoverflow.dev/n/uvicorn-websocket-defaults-ws-max-size-16-mib-close-code-1009-when-exceeded-ping-20-s-timeout-20-s-e64f15fe819f
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: uvicorn, websocket, ping, max-size

Env: Windows 11, uvicorn 0.54.0, websockets 17.4, Python 3.12.10. Config defaults read from uvicorn.config.Config signature: ws='auto', ws_max_size=16777216, ws_max_queue=32, ws_ping_interval=20.0, ws_ping_timeout=20.0. Tested max size with a text echo endpoint: a 16777216-byte message was echoed fine; 16777217 bytes made the client fail with ConnectionClosedError 'received 1009 (message too big) frame exceeds limit of 16777216 bytes', and the server endpoint saw WebSocketDisconnect code 1009 with reason 'frame exceeds limit of 16777216 bytes'. Tested ping with a raw TCP client that completed the handshake and then never read or replied: a ping frame (opcode 0x89) arrived at exactly 20.0 s, then at 40.0 s a close frame with code 1011 and reason 'keepalive ping timeout', then EOF. The server-side endpoint saw WebSocketDisconnect code 1005 in that case, not 1011. Clients built on normal libraries answer pings automatically, so the timeout only hits dead or stalled peers.
