User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
Steps to reproduce:
I've created a jsfiddle with the steps.
- Create 2 peerConnections
- Negotiate both
- Create a datachannel
- Renegotiate again
- Repeat 3, 4 several times
When you reproduce those steps, datachannel.id uses an invalid id, 65535, and it's incorrect.
Looks like when the peerConnection creates a data channel using the id 65535 which is invalid and it is reserved by SCTP for the SCTP INIT message, that's why I think that it is screwing up the whole SCTP stack.
Basically, those stream ids are picked by client and server based on the SCTP role as defined here https://tools.ietf.org/html/draft-ietf-rtcweb-data-protocol-09] for in-band negotiation (Section 4):
To avoid collisions where both sides try to open a Data Channel with
the same Stream Identifiers, each side MUST use Streams with either
even or odd Stream Identifiers when sending a DATA_CHANNEL_OPEN
message. When using SCTP over DTLS
[I-D.ietf-tsvwg-sctp-dtls-encaps], the method used to determine which
side uses odd or even is based on the underlying DTLS connection
role: the side acting as the DTLS client MUST use Streams with even
Stream Identifiers, the side acting as the DTLS server MUST use
Streams with odd Stream Identifiers.
Available range for stream ids are defined here:
Stream: A unidirectional stream of an SCTP association. It is
uniquely identified by an SCTP stream identifier (0-65534). Note:
the SCTP stream identifier 65535 is reserved due to SCTP INIT and
INIT-ACK chunks only allowing a maximum of 65535 Streams to be
Some aditional references regarding the stream id are included in the PeerConnection API as well:
If [[DataChannelId]] is equal to 65535, which is greater than the maximum allowed ID of 65534 but still qualifies as an unsigned short, throw a TypeError.NOTE
If the [[DataChannelId]] slot is null after this step, it will be populated once the DTLS role is determined during the process of setting an RTCSessionDescription.
All datachannels should have id's valid.