0

Specs:

  • Java 1.8
  • Tomcat 8.0.39
  • WebSocket API 1.1

Occasionally one of my clients will send a large payload (greater than the default 8192 byte buffer size) and when this happens the server kills the connection with a CloseReason of 1009 (Too Large). I'd rather configure the server to ignore the occasional large message rather than nuking the connection. Is this possible?

preston.m.price
  • 646
  • 1
  • 10
  • 17

1 Answers1

0

Take a look at the documentation for Tomcat 8, this one is for binary messages:

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.

This is also the same for text messages:

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.

Found here: https://tomcat.apache.org/tomcat-8.0-doc/web-socket-howto.html

If you are using WebSocketContainer there is also the following methods: setDefaultMaxBinaryMessageBufferSize and setDefaultMaxTextMessageBufferSize.

Found here: https://tomcat.apache.org/tomcat-8.0-doc/websocketapi/javax/websocket/WebSocketContainer.html

Brendan Lesniak
  • 2,271
  • 4
  • 24
  • 48