Class ReactorNettyWebSocketClient
java.lang.Object
org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient
- All Implemented Interfaces:
- WebSocketClient
WebSocketClient implementation for use with Reactor Netty.- Since:
- 5.0
- Author:
- Rossen Stoyanchev
- 
Constructor SummaryConstructorsConstructorDescriptionDefault constructor.ReactorNettyWebSocketClient(reactor.netty.http.client.HttpClient httpClient) Constructor that accepts an existingHttpClientbuilder with a defaultWebsocketClientSpec.Builder.ReactorNettyWebSocketClient(reactor.netty.http.client.HttpClient httpClient, Supplier<reactor.netty.http.client.WebsocketClientSpec.Builder> builderSupplier) Constructor that accepts an existingHttpClientbuilder and a pre-configuredWebsocketClientSpec.Builder.
- 
Method SummaryModifier and TypeMethodDescriptionreactor.core.publisher.Mono<Void>execute(URI url, HttpHeaders requestHeaders, WebSocketHandler handler) A variant ofWebSocketClient.execute(URI, WebSocketHandler)with custom headers.reactor.core.publisher.Mono<Void>execute(URI url, WebSocketHandler handler) Execute a handshake request to the given url and handle the resulting WebSocket session with the given handler.booleanDeprecated.reactor.netty.http.client.HttpClientReturn the configuredHttpClient.intDeprecated.as of 5.3 in favor ofgetWebsocketClientSpec()reactor.netty.http.client.WebsocketClientSpecBuild an instance ofWebsocketClientSpecthat reflects the current configuration.voidsetHandlePing(boolean handlePing) Deprecated.as of 5.3 in favor of providing a supplier ofWebsocketClientSpec.Builderwith a constructor argumentvoidsetMaxFramePayloadLength(int maxFramePayloadLength) Deprecated.as of 5.3 in favor of providing a supplier ofWebsocketClientSpec.Builderwith a constructor argument
- 
Constructor Details- 
ReactorNettyWebSocketClientpublic ReactorNettyWebSocketClient()Default constructor.
- 
ReactorNettyWebSocketClientpublic ReactorNettyWebSocketClient(reactor.netty.http.client.HttpClient httpClient) Constructor that accepts an existingHttpClientbuilder with a defaultWebsocketClientSpec.Builder.- Since:
- 5.1
 
- 
ReactorNettyWebSocketClientpublic ReactorNettyWebSocketClient(reactor.netty.http.client.HttpClient httpClient, Supplier<reactor.netty.http.client.WebsocketClientSpec.Builder> builderSupplier) Constructor that accepts an existingHttpClientbuilder and a pre-configuredWebsocketClientSpec.Builder.- Since:
- 5.3
 
 
- 
- 
Method Details- 
getHttpClientpublic reactor.netty.http.client.HttpClient getHttpClient()Return the configuredHttpClient.
- 
getWebsocketClientSpecpublic reactor.netty.http.client.WebsocketClientSpec getWebsocketClientSpec()Build an instance ofWebsocketClientSpecthat 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.3
 
- 
setMaxFramePayloadLengthDeprecated.as of 5.3 in favor of providing a supplier ofWebsocketClientSpec.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.2
 
- 
getMaxFramePayloadLengthDeprecated.as of 5.3 in favor ofgetWebsocketClientSpec()Return the configuredmaxFramePayloadLength.- Since:
- 5.2
 
- 
setHandlePingDeprecated.as of 5.3 in favor of providing a supplier ofWebsocketClientSpec.Builderwith a constructor argumentConfigure whether to let ping frames through to be handled by theWebSocketHandlergiven to the execute 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
 
- 
getHandlePingDeprecated.as of 5.3 in favor ofgetWebsocketClientSpec()Return the configuredsetHandlePing(boolean).- Since:
- 5.2.4
 
- 
executeDescription copied from interface:WebSocketClientExecute a handshake request to the given url and handle the resulting WebSocket session with the given handler.- Specified by:
- executein interface- WebSocketClient
- Parameters:
- url- the handshake url
- handler- the handler of the WebSocket session
- Returns:
- completion Mono<Void>to indicate the outcome of the WebSocket session handling.
 
- 
executepublic reactor.core.publisher.Mono<Void> execute(URI url, HttpHeaders requestHeaders, WebSocketHandler handler) Description copied from interface:WebSocketClientA variant ofWebSocketClient.execute(URI, WebSocketHandler)with custom headers.- Specified by:
- executein interface- WebSocketClient
- Parameters:
- url- the handshake url
- requestHeaders- custom headers for the handshake request
- handler- the handler of the WebSocket session
- Returns:
- completion Mono<Void>to indicate the outcome of the WebSocket session handling.
 
 
- 
getWebsocketClientSpec()