The JSR-356 Java WebSocket 1.0 implementation is only available when Tomcat
is running on Java 7 or later.
Tomcat provides a number of Tomcat specific configuration options for
WebSocket. It is anticipated that these will be absorbed into the WebSocket
specification over time.
The write timeout used when sending WebSocket messages in blocking mode
defaults to 20000 milliseconds (20 seconds). This may be changed by setting
the property org.apache.tomcat.websocket.BLOCKING_SEND_TIMEOUT
in the user properties collection attached to the WebSocket session. The
value assigned to this property should be a Long
and represents
the timeout to use in milliseconds. For an infinite timeout, use
-1
.
The default buffer size for binary messages is 8192 bytes. This may be
changed for a web application by setting the servlet context initialization
parameter org.apache.tomcat.websocket.binaryBufferSize
to the
desired value in bytes.
The default buffer size for text messages is 8192 bytes. This may be
changed for a web application by setting the servlet context initialization
parameter org.apache.tomcat.websocket.textBufferSize
to the
desired value in bytes.
The Java WebSocket specification 1.0 does not permit programmatic deployment
after the first endpoint has started a WebSocket handshake. By default,
Tomcat continues to permit additional programmatic deployment. This
behavior is controlled by the
org.apache.tomcat.websocket.noAddAfterHandshake
servlet context
initialization parameter. The default may be changed by setting the
org.apache.tomcat.websocket.STRICT_SPEC_COMPLIANCE
system
property to true
but any explicit setting on the servlet context
will always take priority.