1009 communication protocol_error ai_generated true

WebSocket frame exceeds maximum size: received 1048576 bytes, max allowed 65536 bytes (Error code 1009)

ID: communication/websocket-1009-message-too-big

Also available as: JSON · Markdown · 中文
84%Fix Rate
87%Confidence
1Evidence
2023-11-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
RFC 6455 active
Node.js ws library 8.12.0 active
Python websockets 12.0 active
Go gorilla/websocket 1.5.0 active

Root Cause

WebSocket server or client closes connection with code 1009 because the received message payload exceeds the configured maximum frame size, typically due to unsplit large payloads or misconfigured limits.

generic

中文

WebSocket 服务器或客户端以代码 1009 关闭连接,因为接收的消息负载超过配置的最大帧大小,通常是由于未分割的大负载或配置错误的限制。

Official Documentation

https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/statusCode

Workarounds

  1. 90% success Implement message splitting on the sender: break large payloads (e.g., > 64KB) into multiple WebSocket messages with a sequence identifier, then reassemble on the receiver. This avoids exceeding the frame limit.
    Implement message splitting on the sender: break large payloads (e.g., > 64KB) into multiple WebSocket messages with a sequence identifier, then reassemble on the receiver. This avoids exceeding the frame limit.
  2. 85% success Increase the server's max frame size (e.g., in Python websockets: set 'max_size' parameter to None or a larger value like 10MB).
    Increase the server's max frame size (e.g., in Python websockets: set 'max_size' parameter to None or a larger value like 10MB).
  3. 80% success Use compression (e.g., permessage-deflate extension) to reduce payload size below the limit, if both client and server support it.
    Use compression (e.g., permessage-deflate extension) to reduce payload size below the limit, if both client and server support it.

中文步骤

  1. Implement message splitting on the sender: break large payloads (e.g., > 64KB) into multiple WebSocket messages with a sequence identifier, then reassemble on the receiver. This avoids exceeding the frame limit.
  2. Increase the server's max frame size (e.g., in Python websockets: set 'max_size' parameter to None or a larger value like 10MB).
  3. Use compression (e.g., permessage-deflate extension) to reduce payload size below the limit, if both client and server support it.

Dead Ends

Common approaches that don't work:

  1. 60% fail

    Increasing the max frame size on the client only shifts the problem; the server may still enforce a smaller limit, causing asymmetric failures.

  2. 75% fail

    Disabling fragmentation entirely (e.g., setting 'permessage-deflate' off) doesn't reduce payload size and may not be supported by all libraries.

  3. 70% fail

    Switching to a different WebSocket library without adjusting limits often results in the same default cap (e.g., 65536 bytes in many implementations).