Class WebSocketServerProtocolConfig

java.lang.Object
io.netty.handler.codec.http.websocketx.WebSocketServerProtocolConfig

public final class WebSocketServerProtocolConfig extends Object
WebSocket server configuration.

Security note: By default no validation of the Origin header is performed during the handshake. Browsers do not apply the same-origin policy to WebSocket connections and send ambient credentials (like cookies) with the handshake request, so applications that authenticate WebSocket connections using such credentials are exposed to Cross-Site WebSocket Hijacking unless they validate the Origin header. Such applications must configure WebSocketServerProtocolConfig.Builder.allowedOrigins(String...) (or perform an equivalent check in a handler placed before WebSocketServerProtocolHandler).

  • Field Details

    • DEFAULT_HANDSHAKE_TIMEOUT_MILLIS

      static final long DEFAULT_HANDSHAKE_TIMEOUT_MILLIS
      See Also:
    • DEFAULT_FORCE_CLOSE_TIMEOUT_MILLIS

      static final long DEFAULT_FORCE_CLOSE_TIMEOUT_MILLIS
      See Also:
    • websocketPath

      private final String websocketPath
    • subprotocols

      private final String subprotocols
    • checkStartsWith

      private final boolean checkStartsWith
    • handshakeTimeoutMillis

      private final long handshakeTimeoutMillis
    • forceCloseTimeoutMillis

      private final long forceCloseTimeoutMillis
    • handleCloseFrames

      private final boolean handleCloseFrames
    • sendCloseFrame

      private final WebSocketCloseStatus sendCloseFrame
    • dropPongFrames

      private final boolean dropPongFrames
    • decoderConfig

      private final WebSocketDecoderConfig decoderConfig
    • allowedOrigins

      private final Set<String> allowedOrigins
  • Constructor Details

    • WebSocketServerProtocolConfig

      private WebSocketServerProtocolConfig(String websocketPath, String subprotocols, boolean checkStartsWith, long handshakeTimeoutMillis, long forceCloseTimeoutMillis, boolean handleCloseFrames, WebSocketCloseStatus sendCloseFrame, boolean dropPongFrames, WebSocketDecoderConfig decoderConfig, Set<String> allowedOrigins)
  • Method Details

    • websocketPath

      public String websocketPath()
    • subprotocols

      public String subprotocols()
    • checkStartsWith

      public boolean checkStartsWith()
    • handshakeTimeoutMillis

      public long handshakeTimeoutMillis()
    • forceCloseTimeoutMillis

      public long forceCloseTimeoutMillis()
    • handleCloseFrames

      public boolean handleCloseFrames()
    • sendCloseFrame

      public WebSocketCloseStatus sendCloseFrame()
    • dropPongFrames

      public boolean dropPongFrames()
    • decoderConfig

      public WebSocketDecoderConfig decoderConfig()
    • allowedOrigins

      public Set<String> allowedOrigins()
      Returns the (lower-cased) origins that are allowed to open a WebSocket connection, or an empty set if the Origin header is not validated.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toBuilder

    • newBuilder

      public static WebSocketServerProtocolConfig.Builder newBuilder()