WebSocket CodesΒΆ

The WebSocket protocol specification defines codes for closing connections that should be used during client-server communication.

The following table provides details of these codes, as defined in RFC 6455. Codes in bold are deployed by the server.

Code

Meaning

Description

1000

Normal Closure

Indicates normal closure.

1001

Going Away

Indicates that the endpoint is being ended.

1002

Protocol Error

Indicates that the endpoint is closing the connection due to protocol error.

1003

Cannot Accept

Indicates that the connection was ended because the endpoint received a type of data that it cannot be accepted.

1006

Closed Abnormally

Indicates that the connection was ended because an internal error occurred.

1007

Not Consistent

Indicates that the connection was ended because the endpoint received some data that is not consistent with the message type.

1009

Too Big

Indicates that the connection was ended because the endpoint received a type of data that it is too big to be processed.

1011

Unexpected Condition

Indicates that the connection was ended because the server found an unexpected condition.

RFC also defines the usage ranges for the codes:

0-999

Codes in this range are not used.

1000-2999

Reserved for public definition of the protocol, future revisions and extensions.

3000-3999

Reserved for use in libraries, frameworks and applications. These codes are registered directly by IANA (Internet Assigned Numbers Authority).

4000-4999

Reserved for private use and cannot be registered. Codes in this range can be used in common accord by applications.