I am trying to send a large message (>130k) to a CometD server that is running under Jetty 9. When the server receives this large message, it generates the following exception:
org.eclipse.jetty.websocket.api.MessageTooLargeException: Text message size [130353] exceeds maximum size [65536]
at org.eclipse.jetty.websocket.api.WebSocketPolicy.assertValidTextMessageSize(WebSocketPolicy.java:140)
at org.eclipse.jetty.websocket.common.Parser.assertSanePayloadLength(Parser.java:127)
at org.eclipse.jetty.websocket.common.Parser.parseFrame(Parser.java:482)
at org.eclipse.jetty.websocket.common.Parser.parse(Parser.java:254)
at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.readParse(AbstractWebSocketConnection.java:632)
at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.onFillable(AbstractWebSocketConnection.java:480)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Thread.java:745)
[qtp83954662-20] INFO org.cometd.websocket.server.WebSocketTransport$WebSocketScheduler$1 - WebSocket Error, Address: null
...
(the rest removed for brevity)
I understand what the problem is, and have looked at the CometD documentation. According to the documentation, you can change the buffer size and the maximum message size using the initialization parameters: ws.bufferSize and ws.maxMessageSize. I set those parameters in my web.xml file and restarted Jetty, but the parameter settings seem to have no effect. I am still getting the exact same exception, because the buffer size remains unchanged.
The settings for the web.xml file are provided below:
<servlet>
<servlet-name>cometd</servlet-name>
<servlet-class>org.cometd.server.CometDServlet</servlet-class>
<init-param>
<param-name>ws.bufferSize</param-name>
<param-value>400000</param-value>
</init-param>
<init-param>
<param-name>ws.maxMessageSize</param-name>
<param-value>400000</param-value>
</init-param>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>cometd</servlet-name>
<url-pattern>/cometd/*</url-pattern>
</servlet-mapping>
Am I missing something? How can I set the maximum message size in a CometD server and have the server actually use that message size?