- All Implemented Interfaces:
Serializable
,Comparable<WebSocketStatus>
,Constable
Represents WebSocket status codes as defined by RC 6455 Section 7.4.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionThe server was acting as a gateway or proxy and received an invalid response from the upstream server.Designated for use in applications expecting a status code to indicate that the connection was closed abnormally, e.g., without sending or receiving a Close control frame.An endpoint is "going away", such as a server going down or a browser having navigated away from a page.A server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request.An endpoint is terminating the connection because it has received data within a message that was not consistent with the type of the message (e.g., non-UTF-8 [RFC3629] data within a text message).An endpoint (client) is terminating the connection because it has expected the server to negotiate one or more extension, but the server didn't return them in the response message of the WebSocket handshake.An endpoint is terminating the connection because it has received a message that is too big for it to process.Designated for use in applications expecting a status code to indicate that no status code was actually present.A normal closure, meaning that the purpose for which the connection was established has been fulfilled.An endpoint is terminating the connection because it has received a message that violates its policy.An endpoint is terminating the connection due to a protocol error.Indicates that the service is restarted.It is designated for use in applications expecting a status code to indicate that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified).Indicates that the service is experiencing overload.An endpoint is terminating the connection because it has received a type of data it cannot accept (e.g., an endpoint that understands only text data MAY send this if it receives a binary message). -
Method Summary
Modifier and TypeMethodDescriptionshort
getCode()
Returns the actual WebSocket status code.Returns the reason describing the status.static WebSocketStatus
valueOf
(short code) Returns the status correspoding to the specified code.static WebSocketStatus
Returns the enum constant of this class with the specified name.static WebSocketStatus[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
NORMAL_CLOSURE
A normal closure, meaning that the purpose for which the connection was established has been fulfilled.
-
ENDPOINT_UNAVAILABLE
An endpoint is "going away", such as a server going down or a browser having navigated away from a page.
-
PROTOCOL_ERROR
An endpoint is terminating the connection due to a protocol error.
-
UNSUPPORTED_DATA
An endpoint is terminating the connection because it has received a type of data it cannot accept (e.g., an endpoint that understands only text data MAY send this if it receives a binary message).
-
NO_STATUS
Designated for use in applications expecting a status code to indicate that no status code was actually present.
This is a reserved value that MUST NOT be set as a status code in a Close control frame by an endpoint.
-
CLOSED_ABNORMALLY
Designated for use in applications expecting a status code to indicate that the connection was closed abnormally, e.g., without sending or receiving a Close control frame.
This is a reserved value that MUST NOT be set as a status code in a Close control frame by an endpoint.
-
INVALID_PAYLOAD_DATA
An endpoint is terminating the connection because it has received data within a message that was not consistent with the type of the message (e.g., non-UTF-8 [RFC3629] data within a text message).
-
POLICY_VIOLATION
An endpoint is terminating the connection because it has received a message that violates its policy.
This is a generic status code that can be returned when there is no other more suitable status code (e.g., 1003 or 1009) or if there is a need to hide specific details about the policy.
-
MESSAGE_TOO_BIG
An endpoint is terminating the connection because it has received a message that is too big for it to process.
-
MANDATORY_EXTENSION
An endpoint (client) is terminating the connection because it has expected the server to negotiate one or more extension, but the server didn't return them in the response message of the WebSocket handshake.
The list of extensions that are needed SHOULD appear in the /reason/ part of the Close frame. Note that this status code is not used by the server, because it can fail the WebSocket handshake instead.
-
INTERNAL_SERVER_ERROR
A server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request.
-
SERVICE_RESTART
Indicates that the service is restarted.
A client may reconnect, and if it choses to do, should reconnect using a randomized delay of 5 - 30s.
-
TRY_AGAIN_LATER
Indicates that the service is experiencing overload.
A client should only connect to a different IP (when there are multiple for the target) or reconnect to the same IP upon user action.
-
BAD_GATEWAY
The server was acting as a gateway or proxy and received an invalid response from the upstream server.
-
TLS_HANDSHAKE_ERROR
It is designated for use in applications expecting a status code to indicate that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified).
It is a reserved value that MUST NOT be set as a status code in a Close control frame by an endpoint.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
getCode
public short getCode()Returns the actual WebSocket status code.
- Returns:
- the status code
-
getReason
Returns the reason describing the status.
- Returns:
- a reason
-
valueOf
Returns the status correspoding to the specified code.
- Parameters:
code
- a code- Returns:
- a WebSocket status
- Throws:
IllegalArgumentException
- if the specified code doesn't correspond to a supported status
-