question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RTCDataChannel stream id never reuse

See original GitHub issue

In the transport code, you never reset number to 0 if it reaches the max. https://github.com/aiortc/aiortc/blob/master/src/aiortc/rtcsctptransport.py#L1620

        if stream_id is None:
                while self._data_channel_id in self._data_channels:
                    self._data_channel_id += 2
                stream_id = self._data_channel_id
                self._data_channels[stream_id] = channel
                self._data_channel_id += 2
                channel._setId(stream_id)

it can be ok for a custom client but on the browser, we have a very strict limitation: stream_id < 1024 on Chrome and stream_id < 256 on Firefox. On the Chrome side, you can check MaxChannels param. As you can see, if I need often close and create DataChannel I very quickly reach this limitation.

Also, some details here https://github.com/w3c/webrtc-pc/issues/2158

I suppose should be a way to setup max_stream_id and try reused freed ids.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
lgrahlcommented, Feb 4, 2020

@jlaine You can reuse a stream ID of a stream that has been reset from both sides (incoming and outgoing side).

Code section in RAWRTC for reference: https://github.com/rawrtc/rawrtc-data-channel/blob/5d1105f9b852074250f2fc6c072bd7690c31fea4/src/sctp_transport/transport.c#L1070

Edit: Be aware that, at least in usrsctp, it is quite tricky to implement.

0reactions
jlainecommented, Feb 27, 2020

Thanks @lgrahl !

@stalkerg would you mind giving the PR a try and report back whether it solves your problem?

NOTE: I am well aware there is currently no check that we have not exceeded the maximum number of allowed streams, but at least your stream IDs should get recycled.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stream id of a closed data channel should be reusable - webrtc
Issue 2646: Stream id of a closed data channel should be reusable · 1) Open http://googlechrome.github.io/webrtc/samples/web/content/datachannel/
Read more >
DataChannel max value for "id" before connecting? #2158
Using a stream ID of 65535, would require the pointer array to be maximal. ... RTCDataChannel stream id never reuse aiortc/aiortc#256.
Read more >
A simple RTCDataChannel sample - Web APIs | MDN
Then all the saved references to these objects are set to null to avoid accidental reuse, and the user interface is updated to...
Read more >
How are data channels negotiated between two peers with ...
Firstly: to create any data channel, the peers need to exchange an SDP offer/answer that negotiates the properties of the SCTP connection ...
Read more >
Identifiers for WebRTC's Statistics API - W3C
We also guarantee that the stats id of the deleted object will never be reused for another object. This ensures that an application...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found