WebSocket 1001 Going Away vs 1002 Protocol Error
Both WebSocket 1001 (Going Away) and 1002 (Protocol Error) belong to the WebSocket Close Codes category. 1001 indicates that an endpoint is going away, such as a server shutting down or a browser navigating away from the page. The connection must be closed. Meanwhile, 1002 means that an endpoint is terminating the connection because it received data that violates the WebSocket protocol specification.
Açıklama
An endpoint is going away, such as a server shutting down or a browser navigating away from the page. The connection must be closed.
Gördüğünüzde
The server is shutting down for maintenance, or the user navigated away from the page or closed the browser tab while a WebSocket was open.
Nasıl Düzeltilir
Implement automatic reconnection logic with exponential backoff in your client. If the server is restarting, the client should retry after a short delay.
Açıklama
An endpoint is terminating the connection because it received data that violates the WebSocket protocol specification.
Gördüğünüzde
The WebSocket frame format is invalid — a malformed header, incorrect masking, or a reserved opcode was used. This usually indicates a broken client or proxy.
Nasıl Düzeltilir
Check that both client and server strictly follow RFC 6455 framing rules. Inspect intermediary proxies that may be corrupting WebSocket frames.
Temel Farklar
WebSocket 1001: An endpoint is going away, such as a server shutting down or a browser navigating away from the page. The connection must be closed.
WebSocket 1002: An endpoint is terminating the connection because it received data that violates the WebSocket protocol specification.
You encounter 1001 when the server is shutting down for maintenance, or the user navigated away from the page or closed the browser tab while a WebSocket was open.
You encounter 1002 when the WebSocket frame format is invalid — a malformed header, incorrect masking, or a reserved opcode was used. This usually indicates a broken client or proxy.
Hangisini Ne Zaman Kullanmalı
For 1001 (Going Away): Implement automatic reconnection logic with exponential backoff in your client. If the server is restarting, the client should retry after a short delay. For 1002 (Protocol Error): Check that both client and server strictly follow RFC 6455 framing rules. Inspect intermediary proxies that may be corrupting WebSocket frames.