mirror of
https://github.com/livekit/livekit.git
synced 2026-03-30 13:25:42 +00:00
Issue full reconnect if subscriber PC is closed on ICERestart (#1919)
Server could have closed subscriber PC to aid migration. But, if a resumes lands back on that node, a resume of the participant session is not possible as subscriber PC is already closed. While theoretically possible to form a new subscriber peer conenction, reducing complexity and issuing a full reconnect as this should be a rare case.
This commit is contained in:
@@ -863,7 +863,9 @@ func (p *ParticipantImpl) ICERestart(iceConfig *livekit.ICEConfig) {
|
||||
t.(types.LocalMediaTrack).Restart()
|
||||
}
|
||||
|
||||
p.TransportManager.ICERestart(iceConfig)
|
||||
if err := p.TransportManager.ICERestart(iceConfig); err != nil {
|
||||
p.IssueFullReconnect(types.ParticipantCloseReasonNegotiateFailed)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) OnICEConfigChanged(f func(participant types.LocalParticipant, iceConfig *livekit.ICEConfig)) {
|
||||
|
||||
@@ -72,13 +72,14 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
ErrIceRestartWithoutLocalSDP = errors.New("ICE restart without local SDP settled")
|
||||
ErrNoTransceiver = errors.New("no transceiver")
|
||||
ErrNoSender = errors.New("no sender")
|
||||
ErrNoICECandidateHandler = errors.New("no ICE candidate handler")
|
||||
ErrNoOfferHandler = errors.New("no offer handler")
|
||||
ErrNoAnswerHandler = errors.New("no answer handler")
|
||||
ErrMidNotFound = errors.New("mid not found")
|
||||
ErrIceRestartWithoutLocalSDP = errors.New("ICE restart without local SDP settled")
|
||||
ErrIceRestartOnClosedPeerConnection = errors.New("ICE restart on closed peer connection")
|
||||
ErrNoTransceiver = errors.New("no transceiver")
|
||||
ErrNoSender = errors.New("no sender")
|
||||
ErrNoICECandidateHandler = errors.New("no ICE candidate handler")
|
||||
ErrNoOfferHandler = errors.New("no offer handler")
|
||||
ErrNoAnswerHandler = errors.New("no answer handler")
|
||||
ErrMidNotFound = errors.New("mid not found")
|
||||
)
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@@ -1103,10 +1104,16 @@ func (t *PCTransport) Negotiate(force bool) {
|
||||
}
|
||||
}
|
||||
|
||||
func (t *PCTransport) ICERestart() {
|
||||
func (t *PCTransport) ICERestart() error {
|
||||
if t.pc.ConnectionState() == webrtc.PeerConnectionStateClosed {
|
||||
t.params.Logger.Warnw("trying to restart ICE on closed peer connection", nil)
|
||||
return ErrIceRestartOnClosedPeerConnection
|
||||
}
|
||||
|
||||
t.postEvent(event{
|
||||
signal: signalICERestart,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *PCTransport) ResetShortConnOnICERestart() {
|
||||
|
||||
@@ -521,12 +521,12 @@ func (t *TransportManager) HandleClientReconnect(reason livekit.ReconnectReason)
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TransportManager) ICERestart(iceConfig *livekit.ICEConfig) {
|
||||
func (t *TransportManager) ICERestart(iceConfig *livekit.ICEConfig) error {
|
||||
if iceConfig != nil {
|
||||
t.SetICEConfig(iceConfig)
|
||||
}
|
||||
|
||||
t.subscriber.ICERestart()
|
||||
return t.subscriber.ICERestart()
|
||||
}
|
||||
|
||||
func (t *TransportManager) OnICEConfigChanged(f func(iceConfig *livekit.ICEConfig)) {
|
||||
|
||||
Reference in New Issue
Block a user