Add option to issue full reconnect on data channel error. (#2026)
* Add option to issue full reconnect on data channel error. There are situations where send data packet fails because of "stream closed". It is unclear when that happens. Seems to be after an ICERestart after ICE failed and connection type switching to TURN from ICE. Once the failure happens, it is not recoverable. Potentially, it is recoverable, but unclear where the problem lies. Attempts to reproduce looking at the pattern of failures has been unsuccesful. In the mean time, adding an option to issue full reconnect when send data packet fails. * typo
This commit is contained in:
@@ -662,9 +662,9 @@ func (t *PCTransport) onPeerConnectionStateChange(state webrtc.PeerConnectionSta
|
||||
}
|
||||
|
||||
func (t *PCTransport) onDataChannel(dc *webrtc.DataChannel) {
|
||||
t.params.Logger.Debugw(dc.Label() + " data channel open")
|
||||
switch dc.Label() {
|
||||
case ReliableDataChannel:
|
||||
t.params.Logger.Debugw("reliable data channel open")
|
||||
t.lock.Lock()
|
||||
t.reliableDC = dc
|
||||
t.reliableDCOpened = true
|
||||
@@ -677,7 +677,6 @@ func (t *PCTransport) onDataChannel(dc *webrtc.DataChannel) {
|
||||
|
||||
t.maybeNotifyFullyEstablished()
|
||||
case LossyDataChannel:
|
||||
t.params.Logger.Debugw("lossy data channel open")
|
||||
t.lock.Lock()
|
||||
t.lossyDC = dc
|
||||
t.lossyDCOpened = true
|
||||
@@ -762,7 +761,6 @@ func (t *PCTransport) AddTrack(trackLocal webrtc.TrackLocal, params types.AddTra
|
||||
}
|
||||
|
||||
configureAudioTransceiver(transceiver, params.Stereo, !params.Red || !t.params.ClientInfo.SupportsAudioRED())
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -833,7 +831,7 @@ func (t *PCTransport) CreateDataChannel(label string, dci *webrtc.DataChannelIni
|
||||
}
|
||||
|
||||
dcErrorHandler := func(err error) {
|
||||
t.params.Logger.Errorw(dc.Label()+" data channel close", err)
|
||||
t.params.Logger.Errorw(dc.Label()+" data channel error", err)
|
||||
}
|
||||
|
||||
t.lock.Lock()
|
||||
@@ -924,6 +922,10 @@ func (t *PCTransport) SendDataPacket(dp *livekit.DataPacket, data []byte) error
|
||||
return ErrDataChannelUnavailable
|
||||
}
|
||||
|
||||
if t.pc.ConnectionState() == webrtc.PeerConnectionStateFailed {
|
||||
return ErrTransportFailure
|
||||
}
|
||||
|
||||
return dc.Send(data)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user