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:
Raja Subramanian
2023-09-01 17:59:25 +05:30
committed by GitHub
parent b4efbe21a1
commit 6509bb0325
6 changed files with 34 additions and 6 deletions
+11 -1
View File
@@ -16,6 +16,7 @@ package rtc
import (
"context"
"io"
"os"
"strconv"
"strings"
@@ -24,6 +25,7 @@ import (
lru "github.com/hashicorp/golang-lru/v2"
"github.com/pion/rtcp"
"github.com/pion/sctp"
"github.com/pion/sdp/v3"
"github.com/pion/webrtc/v3"
"github.com/pkg/errors"
@@ -103,6 +105,7 @@ type ParticipantParams struct {
GetParticipantInfo func(pID livekit.ParticipantID) *livekit.ParticipantInfo
ReconnectOnPublicationError bool
ReconnectOnSubscriptionError bool
ReconnectOnDataChannelError bool
VersionGenerator utils.TimedVersionGenerator
TrackResolver types.MediaTrackResolver
DisableDynacast bool
@@ -2143,6 +2146,8 @@ func (p *ParticipantImpl) IssueFullReconnect(reason types.ParticipantCloseReason
scr = types.SignallingCloseReasonFullReconnectPublicationError
case types.ParticipantCloseReasonSubscriptionError:
scr = types.SignallingCloseReasonFullReconnectSubscriptionError
case types.ParticipantCloseReasonDataChannelError:
scr = types.SignallingCloseReasonFullReconnectDataChannelError
case types.ParticipantCloseReasonNegotiateFailed:
scr = types.SignallingCloseReasonFullReconnectNegotiateFailed
}
@@ -2251,7 +2256,12 @@ func (p *ParticipantImpl) SendDataPacket(dp *livekit.DataPacket, data []byte) er
}
err := p.TransportManager.SendDataPacket(dp, data)
if err == nil {
if err != nil {
if (err == sctp.ErrStreamClosed || err == io.ErrClosedPipe) && p.params.ReconnectOnDataChannelError {
p.params.Logger.Infow("issuing full reconnect on data channel error")
p.IssueFullReconnect(types.ParticipantCloseReasonDataChannelError)
}
} else {
p.dataChannelStats.AddBytes(uint64(len(data)), true)
}
return err