Cannot use more than 5 WebRTC datachannels
Hello,
It seems opening more than 5 datachannels causes strange "Invalid argument" errors.
I am attaching a simple program, based on the WebRTC examples, to reproduce the issue.
Please notice how, if you only open 5 data channels (line 172):
for (int i = 0; i < 5; i++)
everything works fine (you can see the on_data_channel callback firing on the other end).
However, if you open 6 or more data channels (e.g. by replacing 5 with a grater number at line 172), the other end only receives the first 5 ones and a lot of strange errors follow. For instance, this is the output for 8 data channels:
Starting pipeline
main: creating chan-0
main: creating chan-1
main: creating chan-2
main: creating chan-3
main: creating chan-4
main: creating chan-5
main: creating chan-6
main: creating chan-7
Created offer:
v=0
o=- 901154949399953672 0 IN IP4 0.0.0.0
s=-
t=0 0
a=ice-options:trickle
m=video 9 UDP/TLS/RTP/SAVPF 96
c=IN IP4 0.0.0.0
a=setup:actpass
a=ice-ufrag:2MHeOf1X3zc52s7z0MtPfQqjlRb2j644
a=ice-pwd:zLwQt/kjQeJLAhebGXdoKuTaCVWVlzrp
a=rtcp-mux
a=rtcp-rsize
a=sendrecv
a=rtpmap:96 VP8/90000
a=rtcp-fb:96 nack pli
a=framerate:30
a=ssrc:2164201911 msid:user724377342@host-f566b918 webrtctransceiver0
a=ssrc:2164201911 cname:user724377342@host-f566b918
a=mid:video0
a=fingerprint:sha-256 11:4F:20:3C:5C:DD:DD:47:CB:4C:E1:06:9D:7D:BB:99:F9:82:2B:6D:F2:E4:9C:34:7F:AD:33:80:DC:D6:B2:D7
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 0.0.0.0
a=setup:actpass
a=ice-ufrag:G9uaPepQ17prWMkQEmldnS87riGJhHRZ
a=ice-pwd:9z+qqsu9nIzAG+nxt+SWB3CotbgSKxa8
a=mid:application1
a=sctp-port:5000
a=fingerprint:sha-256 11:4F:20:3C:5C:DD:DD:47:CB:4C:E1:06:9D:7D:BB:99:F9:82:2B:6D:F2:E4:9C:34:7F:AD:33:80:DC:D6:B2:D7
Created answer:
v=0
o=- 901154949399953672 0 IN IP4 0.0.0.0
s=-
t=0 0
a=ice-options:trickle
m=video 9 UDP/TLS/RTP/SAVPF 96
c=IN IP4 0.0.0.0
a=ice-ufrag:XSsRi38V/mHGWcdPM9sCRuZIerNCsFX1
a=ice-pwd:85KeI9MWMkPBz4LG12b+Bu8WN2eUtvBF
a=rtcp-mux
a=mid:video0
a=setup:active
a=rtpmap:96 VP8/90000
a=rtcp-fb:96 nack pli
a=sendrecv
a=fingerprint:sha-256 11:4F:20:3C:5C:DD:DD:47:CB:4C:E1:06:9D:7D:BB:99:F9:82:2B:6D:F2:E4:9C:34:7F:AD:33:80:DC:D6:B2:D7
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 0.0.0.0
a=ice-ufrag:/16qAKOarhbHXeklT+lxTFNM361mTDd2
a=ice-pwd:CRqqKFJKPlq6WYmkkt0BqXp/eY4nMAcM
a=mid:application1
a=setup:active
a=sctp-port:5000
a=fingerprint:sha-256 11:4F:20:3C:5C:DD:DD:47:CB:4C:E1:06:9D:7D:BB:99:F9:82:2B:6D:F2:E4:9C:34:7F:AD:33:80:DC:D6:B2:D7
** (test:10972): WARNING **: 18:01:59.921: Error sending data on stream 11: (22) Invalid argument
** (test:10972): WARNING **: 18:01:59.921: Error sending data on stream 13: (22) Invalid argument
** (test:10972): WARNING **: 18:01:59.921: Error sending data on stream 15: (22) Invalid argument
on_data_channel: received chan-0
** (test:10972): WARNING **: 18:01:59.921: Error sending data on stream 11: (22) Invalid argument
** (test:10972): WARNING **: 18:01:59.921: Error sending data on stream 13: (22) Invalid argument
** (test:10972): WARNING **: 18:01:59.921: Error sending data on stream 15: (22) Invalid argument
on_data_channel: received chan-1
on_data_channel: received chan-2
** (test:10972): WARNING **: 18:01:59.922: Error sending data on stream 11: (22) Invalid argument
** (test:10972): WARNING **: 18:01:59.922: Error sending data on stream 13: (22) Invalid argument
on_data_channel: received chan-3
** (test:10972): WARNING **: 18:01:59.922: Error sending data on stream 15: (22) Invalid argument
on_data_channel: received chan-4
** (test:10972): WARNING **: 18:01:59.922: Error sending data on stream 11: (22) Invalid argument
** (test:10972): WARNING **: 18:01:59.923: Error sending data on stream 13: (22) Invalid argument
** (test:10972): WARNING **: 18:01:59.923: Error sending data on stream 15: (22) Invalid argument
** (test:10972): WARNING **: 18:02:00.023: Error sending data on stream 11: (22) Invalid argument
** (test:10972): WARNING **: 18:02:00.023: Error sending data on stream 13: (22) Invalid argument
** (test:10972): WARNING **: 18:02:00.023: Error sending data on stream 15: (22) Invalid argument
** (test:10972): WARNING **: 18:02:00.123: Error sending data on stream 11: (22) Invalid argument
** (test:10972): WARNING **: 18:02:00.123: Error sending data on stream 13: (22) Invalid argument
** (test:10972): WARNING **: 18:02:00.123: Error sending data on stream 15: (22) Invalid argument
^C
Am I using the API correctly? I have tested both 1.15.1 and 1.16.0 and they both exhibit this behaviour.