Class ReactorNettyRequestUpgradeStrategy
java.lang.Object
org.springframework.web.reactive.socket.server.upgrade.ReactorNettyRequestUpgradeStrategy
- All Implemented Interfaces:
RequestUpgradeStrategy
A
RequestUpgradeStrategy for use with Reactor Netty.- Since:
- 5.0
- Author:
- Rossen Stoyanchev
-
Constructor Summary
ConstructorsConstructorDescriptionCreate an instances with a defaultWebsocketServerSpec.Builder.ReactorNettyRequestUpgradeStrategy(Supplier<reactor.netty.http.server.WebsocketServerSpec.Builder> builderSupplier) Create an instance with a pre-configuredWebsocketServerSpec.Builderto use for WebSocket upgrades. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDeprecated.intDeprecated.as of 5.2.6 in favor ofgetWebsocketServerSpec()reactor.netty.http.server.WebsocketServerSpecBuild an instance ofWebsocketServerSpecthat reflects the current configuration.voidsetHandlePing(boolean handlePing) Deprecated.as of 5.2.6 in favor of providing a supplier ofWebsocketServerSpec.Builderwith a constructor argumentvoidsetMaxFramePayloadLength(Integer maxFramePayloadLength) Deprecated.as of 5.2.6 in favor of providing a supplier ofWebsocketServerSpec.Builderwith a constructor argumentreactor.core.publisher.Mono<Void>upgrade(ServerWebExchange exchange, WebSocketHandler handler, String subProtocol, Supplier<HandshakeInfo> handshakeInfoFactory) Upgrade to a WebSocket session and handle it with the given handler.
-
Constructor Details
-
ReactorNettyRequestUpgradeStrategy
public ReactorNettyRequestUpgradeStrategy()Create an instances with a defaultWebsocketServerSpec.Builder.- Since:
- 5.2.6
-
ReactorNettyRequestUpgradeStrategy
public ReactorNettyRequestUpgradeStrategy(Supplier<reactor.netty.http.server.WebsocketServerSpec.Builder> builderSupplier) Create an instance with a pre-configuredWebsocketServerSpec.Builderto use for WebSocket upgrades.- Since:
- 5.2.6
-
-
Method Details
-
getWebsocketServerSpec
public reactor.netty.http.server.WebsocketServerSpec getWebsocketServerSpec()Build an instance ofWebsocketServerSpecthat reflects the current configuration. This can be used to check the configured parameters except for sub-protocols which depend on theWebSocketHandlerthat is used for a given upgrade.- Since:
- 5.2.6
-
setMaxFramePayloadLength
Deprecated.as of 5.2.6 in favor of providing a supplier ofWebsocketServerSpec.Builderwith a constructor argumentConfigure the maximum allowable frame payload length. Setting this value to your application's requirement may reduce denial of service attacks using long data frames.Corresponds to the argument with the same name in the constructor of
WebSocketServerHandshakerFactoryin Netty.By default set to 65536 (64K).
- Parameters:
maxFramePayloadLength- the max length for frames.- Since:
- 5.1
-
getMaxFramePayloadLength
Deprecated.as of 5.2.6 in favor ofgetWebsocketServerSpec()Return the configured max length for frames.- Since:
- 5.1
-
setHandlePing
Deprecated.as of 5.2.6 in favor of providing a supplier ofWebsocketServerSpec.Builderwith a constructor argumentConfigure whether to let ping frames through to be handled by theWebSocketHandlergiven to the upgrade method. By default, Reactor Netty automatically replies with pong frames in response to pings. This is useful in a proxy for allowing ping and pong frames through.By default this is set to
falsein which case ping frames are handled automatically by Reactor Netty. If set totrue, ping frames will be passed through to theWebSocketHandler.- Parameters:
handlePing- whether to let Ping frames through for handling- Since:
- 5.2.4
-
getHandlePing
Deprecated.as of 5.2.6 in favor ofgetWebsocketServerSpec()Return the configuredsetHandlePing(boolean).- Since:
- 5.2.4
-
upgrade
public reactor.core.publisher.Mono<Void> upgrade(ServerWebExchange exchange, WebSocketHandler handler, @Nullable String subProtocol, Supplier<HandshakeInfo> handshakeInfoFactory) Description copied from interface:RequestUpgradeStrategyUpgrade to a WebSocket session and handle it with the given handler.- Specified by:
upgradein interfaceRequestUpgradeStrategy- Parameters:
exchange- the current exchangehandler- handler for the WebSocket sessionsubProtocol- the selected sub-protocol got the handlerhandshakeInfoFactory- factory to create HandshakeInfo for the WebSocket session- Returns:
- completion
Mono<Void>to indicate the outcome of the WebSocket session handling.
-
getWebsocketServerSpec()