public final class CloseCodes extends Object
According to Section 5.5.1, a status code is a "2-byte unsigned integer (in network byte order)". In Java, we will use 'int' (signed 4-byte integer) to store it.
Note that comments for public constants are taken from the RFC6455.
ReasonForClosure
Modifier and Type | Field and Description |
---|---|
static int |
CLIENT_EXPECTED_EXTENSIONS_FROM_SERVER
1010 indicates that 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.
|
static int |
CONNECTION_CLOSED_ABNORMALLY
1006 is a reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint.
|
static int |
GOING_AWAY
1001 indicates that an endpoint is "going away", such as a server going down or a browser having navigated away
from a page.
|
static int |
INVALID_INCOMING_DATA_TYPE
1003 indicates that 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).
|
static int |
MESSAGE_TO_BIG
1009 indicates that an endpoint is terminating the connection because it has received a message that is too big
for it to process.
|
static int |
NO_STATUS_PROVIDED
1005 is a reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint.
|
static int |
NORMAL_CLOSURE
1000 indicates a normal closure, meaning that the purpose for which the connection was established has been
fulfilled.
|
static int |
POLICY_VIOLATION
1008 indicates that an endpoint is terminating the connection because it has received a message that violates its
policy.
|
static int |
PROTOCOL_ERROR
1002 indicates that an endpoint is terminating the connection due to a protocol error.
|
static int |
RECEIVED_INCONSISTENT_DATA
1007 indicates that 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).
|
static int |
RESERVED_1004
Reserved.
|
static int |
SERVER_CANNOT_FULFILL_REQUEST
1011 indicates that a server is terminating the connection because it encountered an unexpected condition that
prevented it from fulfilling the request.
|
static int |
TLS_HANDSHAKE_FAILED
1015 is a reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
canBeUsedInCloseFrame(int code)
Tell if can be used in a close control frame.
|
public static final int CLIENT_EXPECTED_EXTENSIONS_FROM_SERVER
public static final int CONNECTION_CLOSED_ABNORMALLY
public static final int GOING_AWAY
public static final int INVALID_INCOMING_DATA_TYPE
public static final int MESSAGE_TO_BIG
public static final int NO_STATUS_PROVIDED
public static final int NORMAL_CLOSURE
public static final int POLICY_VIOLATION
public static final int PROTOCOL_ERROR
public static final int RECEIVED_INCONSISTENT_DATA
public static final int RESERVED_1004
public static final int SERVER_CANNOT_FULFILL_REQUEST
public static final int TLS_HANDSHAKE_FAILED
public static boolean canBeUsedInCloseFrame(int code)
code
- the code to test