# WebSocket frame exceeds maximum size: 65535 bytes

- **ID:** `communication/websocket-message-too-large-fragmentation`
- **Domain:** communication
- **Category:** protocol_error
- **Verification:** ai_generated
- **Fix Rate:** 82%

## Root Cause

A WebSocket frame payload exceeds the 16-bit length limit (65535 bytes) when the application sends data without enabling fragmentation or using extension frames, violating RFC 6455 section 5.2.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Node.js ws 8.13.0 | active | — | — |
| Python websockets 12.0 | active | — | — |
| Go gorilla/websocket 1.5.1 | active | — | — |
| Java Tyrus 2.0.0 | active | — | — |
| Nginx 1.25.0 | active | — | — |

## Workarounds

1. **Enable WebSocket fragmentation in the sender: for Python websockets, use 'await websocket.send(message, fragment_size=16384)' to automatically split large messages into multiple frames.** (90% success)
   ```
   Enable WebSocket fragmentation in the sender: for Python websockets, use 'await websocket.send(message, fragment_size=16384)' to automatically split large messages into multiple frames.
   ```
2. **Implement application-level chunking: split the payload into chunks of < 65535 bytes on the client and reassemble on the server using a sequence ID.** (85% success)
   ```
   Implement application-level chunking: split the payload into chunks of < 65535 bytes on the client and reassemble on the server using a sequence ID.
   ```
3. **Use WebSocket extensions like 'permessage-deflate' to compress data, reducing payload size below the limit.** (75% success)
   ```
   Use WebSocket extensions like 'permessage-deflate' to compress data, reducing payload size below the limit.
   ```

## Dead Ends

- **Increase the frame size limit in the WebSocket library configuration** — The RFC mandates a maximum frame payload of 2^16-1 bytes for unfragmented frames; increasing the limit may cause protocol-level errors or disconnection. (85% fail)
- **Switch to HTTP/2 streaming instead of WebSocket** — HTTP/2 streaming has different semantics and may not support bidirectional real-time communication; it requires significant application redesign. (90% fail)
- **Compress the data before sending to reduce payload size** — Compression may not be feasible for binary data or real-time streams, and it adds CPU overhead; it also doesn't address the root cause of not using fragmentation. (70% fail)
