# WebSocket close code 1007: Payload data is not consistent with the type of the endpoint's protocol

- **ID:** `api/websocket-close-1007-payload-data`
- **Domain:** api
- **Category:** protocol_error
- **Error Code:** `1007`
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

Server received a binary frame on a text-only WebSocket endpoint, or text frame with invalid UTF-8 encoding.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| websockets 10.0 | active | — | — |
| ws 8.13.0 | active | — | — |
| Spring WebSocket 6.0 | active | — | — |
| nodejs 20.x | active | — | — |

## Workarounds

1. **Ensure the client sends text frames (opcode 0x1) instead of binary frames (opcode 0x2). In JavaScript WebSocket API, always use `ws.send('string data')` not `ws.send(new ArrayBuffer(...))`.** (90% success)
   ```
   Ensure the client sends text frames (opcode 0x1) instead of binary frames (opcode 0x2). In JavaScript WebSocket API, always use `ws.send('string data')` not `ws.send(new ArrayBuffer(...))`.
   ```
2. **If binary data is required, configure the server endpoint to accept binary frames (e.g., in Spring WebSocket use `extends BinaryWebSocketHandler` instead of `TextWebSocketHandler`).** (85% success)
   ```
   If binary data is required, configure the server endpoint to accept binary frames (e.g., in Spring WebSocket use `extends BinaryWebSocketHandler` instead of `TextWebSocketHandler`).
   ```

## Dead Ends

- **** — The issue is protocol-level, not a transient connection glitch. Restarting only resets state temporarily without fixing the frame type mismatch. (90% fail)
- **** — Buffer size doesn't affect frame type validation; the server still rejects binary frames on text endpoints regardless of buffer limits. (95% fail)
