Class WebSocketServerHandshaker13

java.lang.Object
org.jboss.netty.handler.codec.http.websocketx.WebSocketServerHandshaker
org.jboss.netty.handler.codec.http.websocketx.WebSocketServerHandshaker13

public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker

Performs server side opening and closing handshakes for RFC 6455 (originally web socket specification version draft-ietf-hybi-thewebsocketprotocol- 17).

  • Field Details

    • logger

      private static final InternalLogger logger
    • WEBSOCKET_13_ACCEPT_GUID

      public static final String WEBSOCKET_13_ACCEPT_GUID
      See Also:
    • allowExtensions

      private final boolean allowExtensions
  • Constructor Details

    • WebSocketServerHandshaker13

      public WebSocketServerHandshaker13(String webSocketURL, String subprotocols, boolean allowExtensions)
      Constructor using defaults
      Parameters:
      webSocketURL - URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.
      subprotocols - CSV of supported protocols
      allowExtensions - Allow extensions to be used in the reserved bits of the web socket frame
    • WebSocketServerHandshaker13

      public WebSocketServerHandshaker13(String webSocketURL, String subprotocols, boolean allowExtensions, long maxFramePayloadLength)
      Constructor specifying the destination web socket location
      Parameters:
      webSocketURL - URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.
      subprotocols - CSV of supported protocols
      allowExtensions - Allow extensions to be used in the reserved bits of the web socket frame
      maxFramePayloadLength - Maximum allowable frame payload length. Setting this value to your application's requirement may reduce denial of service attacks using long data frames.
  • Method Details

    • handshake

      public ChannelFuture handshake(Channel channel, HttpRequest req)

      Handle the web socket handshake for the web socket specification HyBi versions 13-17. Versions 13-17 share the same wire protocol.

      Browser request to the server:

       GET /chat HTTP/1.1
       Host: server.example.com
       Upgrade: websocket
       Connection: Upgrade
       Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
       Sec-WebSocket-Origin: http://example.com
       Sec-WebSocket-Protocol: chat, superchat
       Sec-WebSocket-Version: 13
       

      Server response:

       HTTP/1.1 101 Switching Protocols
       Upgrade: websocket
       Connection: Upgrade
       Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
       Sec-WebSocket-Protocol: chat
       
      Specified by:
      handshake in class WebSocketServerHandshaker
      Parameters:
      channel - Channel
      req - HTTP request
    • close

      public ChannelFuture close(Channel channel, CloseWebSocketFrame frame)
      Echo back the closing frame and close the connection
      Specified by:
      close in class WebSocketServerHandshaker
      Parameters:
      channel - Channel
      frame - Web Socket frame that was received