RTCDataChannel stream id never reuse
See original GitHub issueIn 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:
- Created 4 years ago
- Comments:7
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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.
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.