Skip to main content
Version: 3.14.x.x LTS

WebSocketServlet

The WebSocket protocol provides full-duplex communication over a single TCP connection (see RFC 6455). The WebSocket handshake is interpreted by HTTP servers as an upgrade request. The WebSocketServlet is responsible for supporting connections over a WebSocket.

The WebSocketServlet can be used for normal HTTP traffic and for traffic with the WebSocket protocol. The WebSocketServlet behaves like a normal HttpConnectorServlet before a protocol upgrade header, or after the WebSocket connection is closed.

Classname:
ch::nevis::isiweb4::servlet::connector::websocket::WebSocketServlet

Library:
libWebSocketServlet.so.1

Configuration

All the configuration attributes of the Http(s)ConnectorServlet (see the chapters: "HttpConnectorServlet" and "HttpsConnectorServlet") can also be configured for theWebSocketServlet, except for theKeepAliveattribute. This attribute has to be set to true (which is the configured default). Otherwise, an exception will be thrown on startup and the WebSocketServlet will not be active. The only required attribute is the InetAddress attribute. All other attributes are optional or have a default value.

Additionally, the WebSocketServlet contains the following attributes:

ProActive

  • Type: boolean
  • Usage Constrains: optional
  • Default: true, conditions are supported

When you set this parameter to "true", nevisProxy will proactively ask for the different WebSocket frames. Some web applications do not support this new feature. In that case, set the ProActiveflag to "false".

Using filters with buffering capabilities before the WebSocketServlet can result in undefined behavior. Filters with buffering capabilities are, for example, the RewriteFilter or the buffering LuaFilter.

The following example shows a simple WebSocketServlet configuration:

<servlet>
<servlet-name>WebSocketServlet</servlet-name>
<servlet-class>ch::nevis::isiweb4::servlet::connector::websocket::WebSocketServlet</servlet-class>

<init-param>
<param-name>InetAddress</param-name>
<param-value>@HOST_NAME@:@HOST_PORT@</param-value>
</init-param>

<init-param>
<param-name>AllowedMethods</param-name>
<param-value>HEAD,POST,GET</param-value>
</init-param>

<init-param>
<param-name>CookieManager</param-name>
<param-value>store:^.*$</param-value>
</init-param>

<init-param>
<param-name>UseSSL</param-name>
<param-value>false</param-value>
</init-param>

<init-param>
<param-name>ResourceManager.RetryTimeout</param-name>
<param-value>0</param-value>
</init-param>

<init-param>
<param-name>ResourceManager.DisablePing</param-name>
<param-value>true</param-value>
</init-param>
</servlet>

<!-- ********** servlet mapping ************** -->

<servlet-mapping>
<servlet-name>WebSocketServlet</servlet-name>
<url-pattern>/path/to/servlet/*</url-pattern>
</servlet-mapping>