Fix wrong SCTP stream parameters in SCTP DataConsumer that consumes from a direct DataProducer#1516
Merged
Fix wrong SCTP stream parameters in SCTP DataConsumer that consumes from a direct DataProducer#1516
DataConsumer that consumes from a direct DataProducer#1516Conversation
DataConsumer that consume …DataConsumer that consumes from a direct DataProducer
jmillan
previously approved these changes
Mar 24, 2025
Member
Author
|
@jmillan please don't approve this yet, I'm still working on the Rust changes. |
Member
I wonder why GH allows approving a draft PR. Please, reassign it to me when done. |
Member
Author
PR ready. |
jmillan
approved these changes
Mar 24, 2025
Member
Author
|
Released in mediasoup 3.15.7. |
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.
Fixes #1515
Details
As exposed in the ticket #1515, let's assume this scenario:
dataProducerwithordered: true(so a reliable DataChannel).directTransportand adirectDataConsumerwhich consumes those WebRTCdataProducerof Alice and Bob.directDataProducercreated in thatdirectTransport.dataConsumerthat consumes messages from thatdirectDataProducer.So what was the problem?
dataProducerscreated on adirectTransportare always reliable. Why? Because they send messages through the mediasoup UnixSocket which is a reliable transport.dataConsumerin awebRtcTransportthat consumes thatdirectDataProducer, such adataConsumershould be reliable (it should havedirectDataConsumer.sctpParameters.ordered === true.webRtcTransport.consumeData()was called withordered: trueexplicitly. But the point is that by default it should be reliable (soordered: true) because we are consuming from adirectDataProducerthat is reliable/ordered by design.ordered: trueinwebRtcTransport.consumeData(), the resultingdataConsumer(which is the one that will deliver messages to the browser) is unreliable (it hasdataConsumer.sctpParameters.ordered === false) so messages sent to the browser could reach the browser out or order and be dispatched by the browser WebRTCPeerConnectionout of order, and some messages could be lost!directTransportblablabla and finally they are sent to Bob via WebRTCdataConsumer. It could happen that Bob receives "C" and "B" (in that order). Ok, that can always happen due to network conditions, but the problem is that, since thedataConsumeris configured as unreliable (it hasordered: false) thedataConsumerin Bob's browser will dispatch "message" events in that wrong order, this is: "C" and "B".dataConsumerwas reliable, then the WebRTC engine of the browser would buffer "C" and "B" and wouldn't dispatch them to the app until "A" is received, and it would dispatch them in order: "A", "B", "C".sctpParameters.maxRetransmits) and if none of the retransmissions of "A" reaches Bob's browser, thewebRtcTransportof Bob in mediasoup side won't emit "sctpstatechange" withstate: 'closed'!Good news
This is fixed in this PR.