DataChannel: reject oversized data messages before they break the channel - #1031
Merged
Conversation
xianshijing-lk
left a comment
Contributor
There was a problem hiding this comment.
some questions / nits
…nnel Sending more than the negotiated SCTP max-message-size makes libwebrtc return success from `sendData` and then abruptly tear down the publisher data channel; every subsequent publish then fails until the next full reconnect. Mirrors the fix from livekit/rust-sdks#1137. Parse `a=max-message-size` (RFC 8841) from the publisher answer SDP in `Room+SignalClientDelegate.didReceiveAnswer`, clamp to a 64000-byte default, and enforce the cap in `DataChannelPair.makeRequest` after serialization — the encoded byte count is what actually goes on the wire. A value of 0 means "no limit". Also logs an error when the publisher channel transitions to `.closed` without an SDK-initiated reset, surfacing the remaining failure modes for diagnosis. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Author
|
@xianshijing-lk the questions refer to the contract defined in livekit/rust-sdks#1137 rather than implementation details, so I'm delaying this PR until the above is merged. |
pblazej
marked this pull request as draft
June 8, 2026 09:08
pblazej
marked this pull request as ready for review
June 9, 2026 08:08
Contributor
Author
|
Confirmed parity with merged livekit/rust-sdks#1137 — 64000-byte default, clamped to that ceiling when the answer SDP advertises more (e.g. libwebrtc's 256 KiB), |
hiroshihorie
approved these changes
Jun 9, 2026
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.
Summary
Sending more than the negotiated SCTP max-message-size makes libwebrtc return success from
sendDataand then abruptly tear down the publisher data channel — every subsequent publish fails until a full reconnect.a=max-message-size(RFC 8841) from the publisher answer SDP, clamp to a 64000-byte default.DataChannelPair.makeRequestafter serialization (encoded byte count = what goes on the wire).0means "no limit"..closedwithout an SDK-initiated reset.Ports the fix from livekit/rust-sdks#1137. Android does the simpler hardcoded-constant variant at
LocalParticipant.kt:984-986.Test plan
oversizedSendRejectedWithInvalidParameter,zeroLimitDisablesTheSizeGuard)xcodebuild buildmacOS clean