{
  "id": "api/websocket-close-1007-payload-data",
  "signature": "WebSocket close code 1007: Payload data is not consistent with the type of the endpoint's protocol",
  "signature_zh": "WebSocket 关闭码 1007：负载数据与端点协议类型不一致",
  "regex": "WebSocket.*close.*1007|Payload data is not consistent",
  "domain": "api",
  "category": "protocol_error",
  "subcategory": null,
  "root_cause": "Server received a binary frame on a text-only WebSocket endpoint, or text frame with invalid UTF-8 encoding.",
  "root_cause_type": "generic",
  "root_cause_zh": "服务器在仅文本的 WebSocket 端点上收到了二进制帧，或文本帧包含无效的 UTF-8 编码。",
  "versions": [
    {
      "version": "websockets 10.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "ws 8.13.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Spring WebSocket 6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "nodejs 20.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The issue is protocol-level, not a transient connection glitch. Restarting only resets state temporarily without fixing the frame type mismatch.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Buffer size doesn't affect frame type validation; the server still rejects binary frames on text endpoints regardless of buffer limits.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "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(...))`.",
      "success_rate": 0.9,
      "how": "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(...))`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If binary data is required, configure the server endpoint to accept binary frames (e.g., in Spring WebSocket use `extends BinaryWebSocketHandler` instead of `TextWebSocketHandler`).",
      "success_rate": 0.85,
      "how": "If binary data is required, configure the server endpoint to accept binary frames (e.g., in Spring WebSocket use `extends BinaryWebSocketHandler` instead of `TextWebSocketHandler`).",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "确保客户端发送文本帧（操作码 0x1）而不是二进制帧（操作码 0x2）。在 JavaScript WebSocket API 中，始终使用 `ws.send('字符串数据')`，不要使用 `ws.send(new ArrayBuffer(...))`。",
    "如果确实需要二进制数据，请将服务器端点配置为接受二进制帧（例如，在 Spring WebSocket 中使用 `extends BinaryWebSocketHandler` 而不是 `TextWebSocketHandler`）。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/code#value_1007",
  "official_doc_section": null,
  "error_code": "1007",
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2024-03-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}