Skip to content

Added configurable maxFramePayloadLength to ReactorNettyWebSocketClient #22367

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

Closed
Closed
Changes from 3 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,7 +64,6 @@ public ReactorNettyWebSocketClient(HttpClient httpClient) {
this.httpClient = httpClient;
}


/**
* Return the configured {@link HttpClient}.
*/
Expand All @@ -81,7 +81,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 All @@ -102,6 +102,14 @@ public Mono<Void> execute(URI url, HttpHeaders requestHeaders, WebSocketHandler
.next();
}

public int getMaxFramePayloadLength() {
return maxFramePayloadLength;
}

public void setMaxFramePayloadLength(int maxFramePayloadLength) {
this.maxFramePayloadLength = maxFramePayloadLength;
}

private void setNettyHeaders(HttpHeaders httpHeaders, io.netty.handler.codec.http.HttpHeaders nettyHeaders) {
httpHeaders.forEach(nettyHeaders::set);
}
Expand Down