Top Description Fields Constructors Methods
org.springframework.web.reactive.socket.server.upgrade

public Class StandardWebSocketUpgradeStrategy

extends Object
implements RequestUpgradeStrategy
Class Inheritance
All Implemented Interfaces
org.springframework.web.reactive.socket.server.RequestUpgradeStrategy
Known Direct Subclasses
org.springframework.web.reactive.socket.server.upgrade.TomcatRequestUpgradeStrategy
Imports
java.util.Collections, .Map, java.util.function.Supplier, jakarta.servlet.http.HttpServletRequest, .HttpServletResponse, jakarta.websocket.Endpoint, jakarta.websocket.server.ServerContainer, .ServerEndpointConfig, reactor.core.publisher.Mono, org.springframework.core.io.buffer.DataBufferFactory, org.springframework.http.server.reactive.ServerHttpRequest, .ServerHttpRequestDecorator, .ServerHttpResponse, .ServerHttpResponseDecorator, org.springframework.lang.Nullable, org.springframework.util.Assert, org.springframework.web.reactive.socket.HandshakeInfo, .WebSocketHandler, org.springframework.web.reactive.socket.adapter.ContextWebSocketHandler, .StandardWebSocketHandlerAdapter, .TomcatWebSocketSession, org.springframework.web.reactive.socket.server.RequestUpgradeStrategy, org.springframework.web.server.ServerWebExchange

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.

Authors
Juergen Hoeller, Violeta Georgieva, Rossen Stoyanchev
Since
6.0
See Also
jakarta.websocket.server.ServerContainer#upgradeHttpToWebSocket

Field Summary

Modifier and TypeField and Description
private Long
private Integer
private Long
private Integer
private static final String
private ServerContainer

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Long
protected ServerContainer
public Integer
public Long
public Integer
private void
public void
setAsyncSendTimeout(Long timeoutInMillis)

Exposes the underlying config option on ServerContainer#setAsyncSendTimeout(long).

public void
public void
setMaxSessionIdleTimeout(Long timeoutInMillis)

Exposes the underlying config option on ServerContainer#setDefaultMaxSessionIdleTimeout(long).

public void
public Mono<Void>
upgrade(ServerWebExchange
the current exchange
exchange
,
WebSocketHandler
handler for the WebSocket session
handler
,
String
the selected sub-protocol got the handler
subProtocol
,
Supplier<HandshakeInfo>
factory to create HandshakeInfo for the WebSocket session
handshakeInfoFactory
)

Implements org.springframework.web.reactive.socket.server.RequestUpgradeStrategy.upgrade.

Upgrade to a WebSocket session and handle it with the given handler.

protected void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

asyncSendTimeoutback to summary
private Long asyncSendTimeout
Annotations
@Nullable
maxBinaryMessageBufferSizeback to summary
private Integer maxBinaryMessageBufferSize
Annotations
@Nullable
maxSessionIdleTimeoutback to summary
private Long maxSessionIdleTimeout
Annotations
@Nullable
maxTextMessageBufferSizeback to summary
private Integer maxTextMessageBufferSize
Annotations
@Nullable
SERVER_CONTAINER_ATTRback to summary
private static final String SERVER_CONTAINER_ATTR
serverContainerback to summary
private ServerContainer serverContainer
Annotations
@Nullable

Constructor Detail

StandardWebSocketUpgradeStrategyback to summary
public StandardWebSocketUpgradeStrategy()

Method Detail

getAsyncSendTimeoutback to summary
public Long getAsyncSendTimeout()
Annotations
@Nullable
getContainerback to summary
protected ServerContainer getContainer(HttpServletRequest request)
getMaxBinaryMessageBufferSizeback to summary
public Integer getMaxBinaryMessageBufferSize()
Annotations
@Nullable
getMaxSessionIdleTimeoutback to summary
public Long getMaxSessionIdleTimeout()
Annotations
@Nullable
getMaxTextMessageBufferSizeback to summary
public Integer getMaxTextMessageBufferSize()
Annotations
@Nullable
initServerContainerback to summary
private void initServerContainer(ServerContainer serverContainer)
setAsyncSendTimeoutback to summary
public void setAsyncSendTimeout(Long timeoutInMillis)

Exposes the underlying config option on ServerContainer#setAsyncSendTimeout(long).

setMaxBinaryMessageBufferSizeback to summary
public void setMaxBinaryMessageBufferSize(Integer bufferSize)

Exposes the underlying config option on ServerContainer#setDefaultMaxBinaryMessageBufferSize(int).

setMaxSessionIdleTimeoutback to summary
public void setMaxSessionIdleTimeout(Long timeoutInMillis)

Exposes the underlying config option on ServerContainer#setDefaultMaxSessionIdleTimeout(long).

setMaxTextMessageBufferSizeback to summary
public void setMaxTextMessageBufferSize(Integer bufferSize)

Exposes the underlying config option on ServerContainer#setDefaultMaxTextMessageBufferSize(int).

upgradeback to summary
public Mono<Void> upgrade(ServerWebExchange exchange, WebSocketHandler handler, String subProtocol, Supplier<HandshakeInfo> handshakeInfoFactory)

Implements org.springframework.web.reactive.socket.server.RequestUpgradeStrategy.upgrade.

Doc from org.springframework.web.reactive.socket.server.RequestUpgradeStrategy.upgrade.

Upgrade to a WebSocket session and handle it with the given handler.

Parameters
exchange:ServerWebExchange

the current exchange

handler:WebSocketHandler

handler for the WebSocket session

subProtocol:String

the selected sub-protocol got the handler

handshakeInfoFactory:Supplier<HandshakeInfo>

factory to create HandshakeInfo for the WebSocket session

Returns:Mono<Void>

completion Mono<Void> to indicate the outcome of the WebSocket session handling.

Annotations
@Override
upgradeHttpToWebSocketback to summary
protected void upgradeHttpToWebSocket(HttpServletRequest request, HttpServletResponse response, ServerEndpointConfig endpointConfig, Map<String, String> pathParams) throws Exception