WebSocket 1000 Normal Closure vs 1003 Unsupported Data
Both WebSocket 1000 (Normal Closure) and 1003 (Unsupported Data) belong to the WebSocket Close Codes category. 1000 indicates that the connection has been closed cleanly, meaning the purpose for which it was established has been fulfilled. Both endpoints agree the session is complete. Meanwhile, 1003 means that an endpoint received a type of data it cannot accept. For example, a text-only endpoint received a binary message, or vice versa.
คำอธิบาย
The connection has been closed cleanly, meaning the purpose for which it was established has been fulfilled. Both endpoints agree the session is complete.
เมื่อคุณพบเห็น
The WebSocket connection closed gracefully after both sides finished exchanging data. This is the expected close code for a successful session.
วิธีแก้ไข
No fix needed — this indicates everything worked as intended. If you did not expect the connection to close, check your application logic for premature close() calls.
คำอธิบาย
An endpoint received a type of data it cannot accept. For example, a text-only endpoint received a binary message, or vice versa.
เมื่อคุณพบเห็น
The client sent a binary frame to a server that only handles text, or a text frame to a binary-only endpoint. The receiver does not know how to process this data type.
วิธีแก้ไข
Verify the message type (text vs binary) matches what the server expects. Update your client to send the correct opcode for the data format.
ความแตกต่างหลัก
WebSocket 1000: The connection has been closed cleanly, meaning the purpose for which it was established has been fulfilled. Both endpoints agree the session is complete.
WebSocket 1003: An endpoint received a type of data it cannot accept. For example, a text-only endpoint received a binary message, or vice versa.
You encounter 1000 when the WebSocket connection closed gracefully after both sides finished exchanging data. This is the expected close code for a successful session.
You encounter 1003 when the client sent a binary frame to a server that only handles text, or a text frame to a binary-only endpoint. The receiver does not know how to process this data type.
ควรใช้อันไหนเมื่อไร
For 1000 (Normal Closure): No fix needed — this indicates everything worked as intended. If you did not expect the connection to close, check your application logic for premature close() calls. For 1003 (Unsupported Data): Verify the message type (text vs binary) matches what the server expects. Update your client to send the correct opcode for the data format.