Enum Class WebSocketStatus

java.lang.Object
java.lang.Enum<WebSocketStatus>
io.inverno.mod.http.base.ws.WebSocketStatus
All Implemented Interfaces:
Serializable, Comparable<WebSocketStatus>, Constable

public enum WebSocketStatus extends Enum<WebSocketStatus>

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 Constants
    Enum Constant
    Description
    The 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 Type
    Method
    Description
    short
    Returns the actual WebSocket status code.
    Returns the reason describing the status.
    valueOf(short code)
    Returns the status correspoding to the specified code.
    Returns the enum constant of this class with the specified name.
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • NORMAL_CLOSURE

      public static final WebSocketStatus NORMAL_CLOSURE

      A normal closure, meaning that the purpose for which the connection was established has been fulfilled.

      RFC 6455 Section 7.4.1

    • ENDPOINT_UNAVAILABLE

      public static final WebSocketStatus ENDPOINT_UNAVAILABLE

      An endpoint is "going away", such as a server going down or a browser having navigated away from a page.

      RFC 6455 Section 7.4.1

    • PROTOCOL_ERROR

      public static final WebSocketStatus PROTOCOL_ERROR

      An endpoint is terminating the connection due to a protocol error.

      RFC 6455 Section 7.4.1

    • UNSUPPORTED_DATA

      public static final WebSocketStatus 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).

      RFC 6455 Section 7.4.1

    • NO_STATUS

      public static final WebSocketStatus 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.

      RFC 6455 Section 7.4.1

    • CLOSED_ABNORMALLY

      public static final WebSocketStatus 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.

      RFC 6455 Section 7.4.1

    • INVALID_PAYLOAD_DATA

      public static final WebSocketStatus 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).

      RFC 6455 Section 7.4.1

    • POLICY_VIOLATION

      public static final WebSocketStatus 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.

      RFC 6455 Section 7.4.1

    • MESSAGE_TOO_BIG

      public static final WebSocketStatus MESSAGE_TOO_BIG

      An endpoint is terminating the connection because it has received a message that is too big for it to process.

      RFC 6455 Section 7.4.1

    • MANDATORY_EXTENSION

      public static final WebSocketStatus 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.

      RFC 6455 Section 7.4.1

    • INTERNAL_SERVER_ERROR

      public static final WebSocketStatus INTERNAL_SERVER_ERROR

      A server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request.

      RFC 6455 Section 7.4.1

    • SERVICE_RESTART

      public static final WebSocketStatus 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.

      Additional WebSocket Close Error Codes

    • TRY_AGAIN_LATER

      public static final WebSocketStatus 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.

      Additional WebSocket Close Error Codes

    • BAD_GATEWAY

      public static final WebSocketStatus BAD_GATEWAY

      The server was acting as a gateway or proxy and received an invalid response from the upstream server.

      WebSocket Subprotocol Close Code: Bad Gateway

    • TLS_HANDSHAKE_ERROR

      public static final WebSocketStatus 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.

      RFC 6455 Section 7.4.1

  • Method Details

    • values

      public static WebSocketStatus[] 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

      public static WebSocketStatus valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • getCode

      public short getCode()

      Returns the actual WebSocket status code.

      Returns:
      the status code
    • getReason

      public String getReason()

      Returns the reason describing the status.

      Returns:
      a reason
    • valueOf

      public static WebSocketStatus valueOf(short code) throws IllegalArgumentException

      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