Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added configurable maxFramePayloadLength to ReactorNettyWebSocketClient #22367

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,17 @@
* {@link WebSocketClient} implementation for use with Reactor Netty.
*
* @author Rossen Stoyanchev
* @author Usman Arshad
* @since 5.0
*/
public class ReactorNettyWebSocketClient implements WebSocketClient {

private static final Log logger = LogFactory.getLog(ReactorNettyWebSocketClient.class);

private int maxFramePayloadLength = 65536;

private final HttpClient httpClient;


/**
* Default constructor.
*/
Expand All @@ -63,14 +64,27 @@ public ReactorNettyWebSocketClient(HttpClient httpClient) {
this.httpClient = httpClient;
}


/**
* Return the configured {@link HttpClient}.
*/
public HttpClient getHttpClient() {
return this.httpClient;
}

/**
* Return the configured maxFramePayloadLength used by the configured {@link HttpClient}.
* Default value of 65536 if not set.
*/
public int getMaxFramePayloadLength() {
return maxFramePayloadLength;
}

/**
* Sets the maxFramePayloadLength to be used by the configured {@link HttpClient}.
*/
public void setMaxFramePayloadLength(int maxFramePayloadLength) {
this.maxFramePayloadLength = maxFramePayloadLength;
}

@Override
public Mono<Void> execute(URI url, WebSocketHandler handler) {
Expand All @@ -81,7 +95,7 @@ public Mono<Void> execute(URI url, WebSocketHandler handler) {
public Mono<Void> execute(URI url, HttpHeaders requestHeaders, WebSocketHandler handler) {
return getHttpClient()
.headers(nettyHeaders -> setNettyHeaders(requestHeaders, nettyHeaders))
.websocket(StringUtils.collectionToCommaDelimitedString(handler.getSubProtocols()))
.websocket(StringUtils.collectionToCommaDelimitedString(handler.getSubProtocols()), getMaxFramePayloadLength())
.uri(url.toString())
.handle((inbound, outbound) -> {
HttpHeaders responseHeaders = toHttpHeaders(inbound);
Expand Down