Skip to content

Propagate max frame length to WebSocket session#36370

Open
aavoronin93 wants to merge 1 commit intospring-projects:mainfrom
aavoronin93:bugfix/webflux-websocket-payload-propagation
Open

Propagate max frame length to WebSocket session#36370
aavoronin93 wants to merge 1 commit intospring-projects:mainfrom
aavoronin93:bugfix/webflux-websocket-payload-propagation

Conversation

@aavoronin93
Copy link

@aavoronin93 aavoronin93 commented Feb 22, 2026

This PR ensures that maxFramePayloadLength from WebsocketClientSpec is passed to ReactorNettyWebSocketSession.

Previously, the session used the default 64KB limit regardless of client configuration, causing io.netty.handler.codec.TooLongFrameException when receiving larger frames from servers like Tomcat or Jetty.

Closes gh-36369

Before After
largePayload_before_fix largePayload_after_fix

I have updated the PR to include a fix for JettyWebSocketClient as well.

The issue was consistent across both clients: session-level limits were not being synchronized with the client-level configuration. For Jetty, I've implemented this by configuring the native session during initialization within the JettyWebSocketHandlerAdapter. For Reactor Netty, the maxFramePayloadLength is now correctly propagated through the session constructor.

I've also expanded the integration tests to verify the fix for both Reactor Netty and Jetty. All tests are passing.

Before After
largePayload_jetty_before_fix largePayload_fixed

@aavoronin93
Copy link
Author

aavoronin93 commented Feb 23, 2026

Updated: While expanding the regression tests to cover all clients in WebSocketIntegrationTests, I discovered that JettyWebSocketClient suffers from the same issue.

Even when the native Jetty client (org.eclipse.jetty.websocket.client.WebSocketClient) is configured with higher limits, the JettyWebSocketSession still defaults to 64KB, leading to: CloseStatus[code=1009, reason=Text message too large: 69,624 > 65,536]

Configuration Log State
org.eclipse.jetty.websocket.client.WebSocketClient#setMaxFrameSize, org.eclipse.jetty.websocket.client.WebSocketClient#setMaxBinaryMessageSize, org.eclipse.jetty.websocket.client.WebSocketClient#setMaxTextMessageSize, org.eclipse.jetty.websocket.client.WebSocketClient#setMaxOutgoingFrames image image

@aavoronin93 aavoronin93 force-pushed the bugfix/webflux-websocket-payload-propagation branch from f5996b0 to 83441b4 Compare February 23, 2026 11:35
@rstoyanchev rstoyanchev self-assigned this Mar 2, 2026
@rstoyanchev rstoyanchev added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Mar 2, 2026
Copy link
Contributor

@rstoyanchev rstoyanchev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Reactor Netty, it looks like originally we had an maxFramePayloadLength field that was passed to ReactorNettyWebSocketSession that was then replaced in favour of the WebSocketClientSpec from Reactor Netty. However, the change 2ed281f to make the switch didn't pass the value into the session constructor, so that's a regression in 7.0.

For Jetty, however, I'm not sure yet why we need to pass the settings from the Jetty WebSocketClient to the Jetty Session, with the latter created by the former. Could you drop the Jetty changes, and submit them as a separate PR, please?

@rstoyanchev rstoyanchev added type: regression A bug that is also a regression and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Mar 2, 2026
@rstoyanchev rstoyanchev added this to the 7.0.6 milestone Mar 2, 2026
This change ensures that maxFramePayloadLength from
WebsocketClientSpec is passed to ReactorNettyWebSocketSession.

Previously, the session used the default 64KB limit regardless
of client configuration, causing TooLongFrameException when
receiving larger frames from servers like Tomcat or Jetty.

Closes spring-projectsgh-36369

Signed-off-by: Artem Voronin <artem.voronin.dev@gmail.com>
@aavoronin93 aavoronin93 force-pushed the bugfix/webflux-websocket-payload-propagation branch from 83441b4 to 3eca440 Compare March 3, 2026 09:00
@aavoronin93
Copy link
Author

After closer investigation, I’ve confirmed that JettyWebSocketClient correctly propagates the limits when properly configured, so I have restored JettyWebSocketClient to its original state.
The initial issues I encountered were due to local misconfiguration.

@aavoronin93 aavoronin93 requested a review from rstoyanchev March 3, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ReactorNettyWebSocketSession ignores maxFramePayloadLength from WebsocketClientSpec

3 participants