Skip to content

Commit

Permalink
Fix Chrome datachannel stuck at closing
Browse files Browse the repository at this point in the history
When close datachannel from chrome, sctp should response with an outgoingResetRequest, otherwise the chrome won't fully close the datachannel.
  • Loading branch information
jerry-tao committed Sep 19, 2022
1 parent d0b7cf3 commit ed0e83d
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions association.go
Original file line number Diff line number Diff line change
Expand Up @@ -2023,12 +2023,41 @@ func (a *Association) resetStreamsIfAny(p *paramOutgoingResetRequest) *packet {
result = reconfigResultInProgress
}

return a.createPacket([]chunk{&chunkReconfig{
paramA: &paramReconfigResponse{
// From draft-ietf-rtcweb-data-channel-13 section-6.7:
// if one side decides to close the data channel, it resets the corresponding
// outgoing stream. When the peer sees that an incoming stream was
// reset, it also resets its corresponding outgoing stream. Once this
// is completed, the data channel is closed.

rsn := a.generateNextRSN()
tsn := a.myNextTSN - 1

c := &chunkReconfig{
paramA: &paramOutgoingResetRequest{
reconfigRequestSequenceNumber: rsn,
reconfigResponseSequenceNumber: p.reconfigRequestSequenceNumber,
result: result,
senderLastTSN: tsn,
streamIdentifiers: p.streamIdentifiers,
},
}})
}
a.reconfigs[rsn] = c // store in the map for retransmission
a.log.Debugf("[%s] sending RECONFIG : rsn=%d tsn=%d",
a.name, rsn, a.myNextTSN-1)

if len(a.reconfigs) > 0 {
a.tReconfig.start(a.rtoMgr.getRTO())
}

return a.createPacket([]chunk{
&chunkReconfig{
paramA: &paramReconfigResponse{
reconfigResponseSequenceNumber: p.reconfigRequestSequenceNumber,
result: result,
},
},
c,
})

}

// Move the chunk peeked with a.pendingQueue.peek() to the inflightQueue.
Expand Down

0 comments on commit ed0e83d

Please sign in to comment.