Class StandardWebSocketUpgradeStrategy

java.lang.Object
org.springframework.web.reactive.socket.server.upgrade.StandardWebSocketUpgradeStrategy
All Implemented Interfaces:
RequestUpgradeStrategy

public class StandardWebSocketUpgradeStrategy extends Object implements RequestUpgradeStrategy
A WebSocket RequestUpgradeStrategy for the Jakarta WebSocket API 2.1+.

This strategy serves as a fallback if no specific server has been detected. It can also be used with Jakarta EE 10 level servers such as Tomcat 10.1 and Undertow 2.3 directly, relying on their built-in Jakarta WebSocket 2.1 support.

Since:
6.0
Author:
Juergen Hoeller, Violeta Georgieva, Rossen Stoyanchev
See Also:
  • ServerContainer.upgradeHttpToWebSocket(Object, Object, ServerEndpointConfig, Map)
  • Constructor Details

    • StandardWebSocketUpgradeStrategy

      public StandardWebSocketUpgradeStrategy()
  • Method Details

    • setAsyncSendTimeout

      public void setAsyncSendTimeout(Long timeoutInMillis)
      Exposes the underlying config option on WebSocketContainer.setAsyncSendTimeout(long).
    • getAsyncSendTimeout

      public @Nullable Long getAsyncSendTimeout()
    • setMaxSessionIdleTimeout

      public void setMaxSessionIdleTimeout(Long timeoutInMillis)
      Exposes the underlying config option on WebSocketContainer.setDefaultMaxSessionIdleTimeout(long).
    • getMaxSessionIdleTimeout

      public @Nullable Long getMaxSessionIdleTimeout()
    • setMaxTextMessageBufferSize

      public void setMaxTextMessageBufferSize(Integer bufferSize)
      Exposes the underlying config option on WebSocketContainer.setDefaultMaxTextMessageBufferSize(int).
    • getMaxTextMessageBufferSize

      public @Nullable Integer getMaxTextMessageBufferSize()
    • setMaxBinaryMessageBufferSize

      public void setMaxBinaryMessageBufferSize(Integer bufferSize)
      Exposes the underlying config option on WebSocketContainer.setDefaultMaxBinaryMessageBufferSize(int).
    • getMaxBinaryMessageBufferSize

      public @Nullable Integer getMaxBinaryMessageBufferSize()
    • upgrade

      public reactor.core.publisher.Mono<Void> upgrade(ServerWebExchange exchange, WebSocketHandler handler, @Nullable String subProtocol, Supplier<HandshakeInfo> handshakeInfoFactory)
      Description copied from interface: RequestUpgradeStrategy
      Upgrade to a WebSocket session and handle it with the given handler.
      Specified by:
      upgrade in interface RequestUpgradeStrategy
      Parameters:
      exchange - the current exchange
      handler - handler for the WebSocket session
      subProtocol - the selected sub-protocol got the handler
      handshakeInfoFactory - factory to create HandshakeInfo for the WebSocket session
      Returns:
      completion Mono<Void> to indicate the outcome of the WebSocket session handling.
    • upgradeHttpToWebSocket

      protected void upgradeHttpToWebSocket(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.websocket.server.ServerEndpointConfig endpointConfig, Map<String,String> pathParams) throws Exception
      Throws:
      Exception
    • getContainer

      protected jakarta.websocket.server.ServerContainer getContainer(jakarta.servlet.http.HttpServletRequest request)