@ -280,9 +280,7 @@ The following example shows the XML configuration equivalent of the preceding ex
@@ -280,9 +280,7 @@ The following example shows the XML configuration equivalent of the preceding ex
NOTE: For client-side WebSocket configuration, you should use `WebSocketContainerFactoryBean`
(XML) or `ContainerProvider.getWebSocketContainer()` (Java configuration).
For Jetty, you need to supply a pre-configured Jetty `WebSocketServerFactory` and plug
that into Spring's `DefaultHandshakeHandler` through your WebSocket Java config.
The following example shows how to do so:
For Jetty, you need to supply a `Consumer` callback to configure the WebSocket server. For example:
[source,java,indent=0,subs="verbatim,quotes"]
----
@ -292,62 +290,20 @@ The following example shows how to do so:
@@ -292,62 +290,20 @@ The following example shows how to do so:
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(echoWebSocketHandler(),
"/echo").setHandshakeHandler(handshakeHandler());
}
@Bean
public DefaultHandshakeHandler handshakeHandler() {
WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.SERVER);
policy.setInputBufferSize(8192);
policy.setIdleTimeout(600000);
JettyRequestUpgradeStrategy upgradeStrategy = new JettyRequestUpgradeStrategy();
@ -62,6 +69,24 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy {
@@ -62,6 +69,24 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy {