fix(datachannel): send DataChannelOpen for pre-negotiated channels (closes #61)#70
Open
nightness wants to merge 1 commit intowebrtc-rs:masterfrom
Open
fix(datachannel): send DataChannelOpen for pre-negotiated channels (closes #61)#70nightness wants to merge 1 commit intowebrtc-rs:masterfrom
nightness wants to merge 1 commit intowebrtc-rs:masterfrom
Conversation
Fixes webrtc-rs#61 — negotiated DataChannels could open but not send. Root cause: DataChannel::dial() skipped queuing the DataChannelOpen DCEP message for pre-negotiated channels (negotiated=true). The SctpHandler calls conn.open_stream() only when it processes a DataChannelOpen write, so no stream was ever registered in the SCTP association. Any subsequent write failed with "Stream not existed". Fix: always queue DataChannelOpen in dial(), for both negotiated and non-negotiated channels. The DCEP exchange opens the SCTP stream on both sides. Also handle ErrStreamAlreadyExist in the DataChannelOpen write path: when both pre-negotiated peers race to send DataChannelOpen simultaneously the remote's message may auto-create the stream first via get_or_create_stream; treat that as non-fatal. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
09db64c to
1dea4fa
Compare
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
Fixes #61 — negotiated DataChannels open but cannot send messages.
Root cause:
DataChannel::dial()skipped theDataChannelOpenDCEP message whenconfig.negotiated == true. TheSctpHandleronly callsconn.open_stream()when processing aDataChannelOpenwrite, so no stream entry was ever created in the SCTP association. Every subsequent write failed with "Stream not existed".Fix:
DataChannelOpenindial(), for both negotiated and non-negotiated channels. The DCEP exchange registers the SCTP stream on both sides.ErrStreamAlreadyExistgracefully in theDataChannelOpenwrite path: when both pre-negotiated peers race to sendDataChannelOpensimultaneously, the remote's packet may auto-create the stream viaget_or_create_streambefore the local outbound write is processed. Treat that as non-fatal and continue to set reliability parameters.Test plan
cargo test -p rtc-datachannelpassescargo test -p rtcpassesnegotiated: Some(5)) on both peers — both sides can exchange messages after connection🤖 Generated with Claude Code