HTTP 500 Internal Server Error vs WebSocket 1011 Internal Error
HTTP 500 and WebSocket 1011 both indicate unexpected server-side errors, but in different communication models. HTTP 500 terminates a single request-response cycle, while WebSocket 1011 closes a long-lived bidirectional connection due to an internal server failure.
설명
The server encountered an unexpected condition that prevented it from fulfilling the request. A generic catch-all for server-side errors.
이 코드를 보게 되는 경우
When an unhandled exception occurs, a database connection fails, or server code has a bug.
해결 방법
Check server logs for the stack trace. Common causes: unhandled exceptions, database errors, misconfigurations.
설명
The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request.
이 코드를 보게 되는 경우
The server hit an unhandled exception or crashed while processing a WebSocket message. This is the WebSocket equivalent of HTTP 500 Internal Server Error.
해결 방법
Check the server-side application logs for stack traces and exceptions. Fix the underlying bug that caused the crash and add proper error handling around message processing.
주요 차이점
HTTP 500 ends a single request; WebSocket 1011 terminates an entire persistent connection.
WebSocket 1011 is sent as a close frame with the status code; HTTP 500 is a response status line.
After HTTP 500, the client can immediately retry the request; after WebSocket 1011, the client must reconnect.
WebSocket 1011 may cause data loss if the server crashes mid-stream; HTTP 500 is atomic per request.
Both indicate a bug or unexpected condition that the server could not handle gracefully.
언제 어떤 것을 사용할지
Return HTTP 500 for unexpected errors in request-response APIs. Send WebSocket close code 1011 when the server must terminate a WebSocket connection due to an unexpected error like an unhandled exception or a backend dependency failure. Clients should implement automatic reconnection with backoff when they receive 1011.