Following settings do have influence on Tyrus behaviour and are NOT part of WebSocket specification. If you are using following configurable options, your application might not be easily transferable to other WebSocket API implementation.
When accessing "wss" URLs, Tyrus client will pick up whatever keystore and truststore is actually set for current JVM instance, but that might not be always convenient. WebSocket API does not have this feature (yet, seeWEBSOCKET_SPEC-210), so Tyrus exposed SSLEngineConfigurator class from Grizzly which can be used for specifying all SSL parameters to be used with current client instance. Additionally, WebSocket API does not have anything like a client, only WebSocketContainer and it does not have any properties, so you need to use Tyrus specific class - ClientManager.
final ClientManager client = ClientManager.createClient(); System.getProperties().put("javax.net.debug", "all"); System.getProperties().put(SSLContextConfigurator.KEY_STORE_FILE, "..."); System.getProperties().put(SSLContextConfigurator.TRUST_STORE_FILE, "..."); System.getProperties().put(SSLContextConfigurator.KEY_STORE_PASSWORD, "..."); System.getProperties().put(SSLContextConfigurator.TRUST_STORE_PASSWORD, "..."); final SSLContextConfigurator defaultConfig = new SSLContextConfigurator(); defaultConfig.retrieve(System.getProperties()); // or setup SSLContextConfigurator using its API. SSLEngineConfigurator sslEngineConfigurator = new SSLEngineConfigurator(defaultConfig, true, false, false); client.getProperties().put(GrizzlyEngine.SSL_ENGINE_CONFIGURATOR, sslEngineConfigurator); client.connectToServer(... , ClientEndpointConfig.Builder.create().build(), new URI("wss://localhost:8181/sample-echo/echo")); }
Sevlet container buffers incoming WebSocket frames and there must a size limit to precede OutOfMemory Exception and potentially DDoS attacks.
Configuration property is named "org.glassfish.tyrus.servlet.incoming-buffer-size"
and you can
set it in web.xml (this particular snipped sets the buffer size to 17000000 bytes (~16M payload):
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <context-param> <param-name>org.glassfish.tyrus.servlet.incoming-buffer-size</param-name> <param-value>17000000</param-value> </context-param> </web-app>
Default value is 4194315, which correspond to 4M plus few bytes to frame headers, so you should be able to receive up to 4M long message without the need to care about this property.