WebSocket 1001 Going Away vs 1014 Bad Gateway
Both WebSocket 1001 (Going Away) and 1014 (Bad Gateway) 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, 1014 means that the server acting as a gateway or proxy received an invalid response from an upstream server it accessed while attempting to fulfill the request.
설명
An endpoint is going away, such as a server shutting down or a browser navigating away from the page. The connection must be closed.
이 코드를 보게 되는 경우
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.
해결 방법
Implement automatic reconnection logic with exponential backoff in your client. If the server is restarting, the client should retry after a short delay.
설명
The server acting as a gateway or proxy received an invalid response from an upstream server it accessed while attempting to fulfill the request.
이 코드를 보게 되는 경우
A reverse proxy or API gateway tried to establish a WebSocket connection to a backend server but received an invalid or no response. The upstream server may be down or misconfigured.
해결 방법
Check the health of the upstream/backend WebSocket server. Verify the proxy configuration routes WebSocket upgrade requests correctly and that the backend is listening on the expected port.
주요 차이점
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 1014: The server acting as a gateway or proxy received an invalid response from an upstream server it accessed while attempting to fulfill the request.
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 1014 when a reverse proxy or API gateway tried to establish a WebSocket connection to a backend server but received an invalid or no response. The upstream server may be down or misconfigured.
언제 어떤 것을 사용할지
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 1014 (Bad Gateway): Check the health of the upstream/backend WebSocket server. Verify the proxy configuration routes WebSocket upgrade requests correctly and that the backend is listening on the expected port.