fix(engineioxide): enforce max_payload on the websocket transport#762
Open
schulzfel wants to merge 1 commit into
Open
fix(engineioxide): enforce max_payload on the websocket transport#762schulzfel wants to merge 1 commit into
schulzfel wants to merge 1 commit into
Conversation
max_payload was only enforced for the polling transport (http request bodies). Websocket connections rode tungstenite's defaults (~64 MiB message / 16 MiB frame), so the configured ceiling was silently unenforced for websocket clients. Map the same ceiling onto inbound websocket frames (max_frame_size) and reassembled messages (max_message_size), giving both transports identical payload enforcement. An oversized message now closes the connection with a transport error instead of being delivered.
Totodore
requested changes
Jul 18, 2026
Totodore
left a comment
Owner
There was a problem hiding this comment.
Thanks for the PR,
However I think we should provide two different options for those two params (frame_size and message_size). These don't have exactly the same implication than max_payload setting.
Also could you propagate this to the socketioxide builder (see https://docs.rs/socketioxide/latest/socketioxide/struct.SocketIoBuilder.html#method.ws_read_buffer_size).
Comment on lines
+120
to
+123
| // Apply the configured `max_payload` ceiling to inbound websocket | ||
| // frames/messages, matching the polling transport. Without this, | ||
| // tungstenite's defaults (~64 MiB message / 16 MiB frame) apply and | ||
| // `max_payload` is silently unenforced for websocket clients. |
Owner
There was a problem hiding this comment.
Suggested change
| // Apply the configured `max_payload` ceiling to inbound websocket | |
| // frames/messages, matching the polling transport. Without this, | |
| // tungstenite's defaults (~64 MiB message / 16 MiB frame) apply and | |
| // `max_payload` is silently unenforced for websocket clients. |
Useless AI-comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
EngineIoConfig.max_payloadis only enforced for the polling transport (HTTP request bodies). Websocket connections are initialized with tungstenite's defaultWebSocketConfig, which allows ~64 MiB messages / 16 MiB frames — so the configured payload ceiling is silently unenforced for websocket clients. A server operator who setsmax_payloadto bound inbound payloads is only actually protected on polling.Fix
Apply the same ceiling to inbound websocket traffic in
ws::on_init:max_frame_sizebounds each frame at parse time andmax_message_sizebounds reassembled fragmented messages, giving both transports identical enforcement. An oversized message now closes the connection with a capacity error (surfaced asDisconnectReason::TransportError) instead of being delivered to the handler.The
max_payloaddoc comment is updated to mention websocket.Tests
New
crates/engineioxide/tests/ws_max_payload.rs(runs with--features __test_harnesslike the other integration tests):ws_message_within_max_payload_is_delivered— messages under the limit still reach the handler.ws_message_exceeding_max_payload_closes_the_connection— an oversized message disconnects withTransportErrorand never reaches the handler.The second test fails without the
ws.rschange and passes with it.Notes
Downstream we currently carry this as a vendored two-line patch on 0.17.1 to safely enable the websocket transport behind a strict payload budget; happy to adjust anything (naming, error surface, backport) to get payload parity landed upstream.