Detect client short ice connection (#1532)
This commit is contained in:
@@ -793,7 +793,7 @@ func (p *ParticipantImpl) ICERestart(iceConfig *livekit.ICEConfig, reason liveki
|
|||||||
t.(types.LocalMediaTrack).Restart()
|
t.(types.LocalMediaTrack).Restart()
|
||||||
}
|
}
|
||||||
|
|
||||||
p.TransportManager.ICERestart(iceConfig, reason == livekit.ReconnectReason_RR_PUBLISHER_FAILED || reason == livekit.ReconnectReason_RR_SUBSCRIBER_FAILED)
|
p.TransportManager.ICERestart(iceConfig, reason)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ParticipantImpl) OnICEConfigChanged(f func(participant types.LocalParticipant, iceConfig *livekit.ICEConfig)) {
|
func (p *ParticipantImpl) OnICEConfigChanged(f func(participant types.LocalParticipant, iceConfig *livekit.ICEConfig)) {
|
||||||
|
|||||||
@@ -495,7 +495,7 @@ func (t *PCTransport) resetShortConn() {
|
|||||||
t.lock.Unlock()
|
t.lock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *PCTransport) isShortConnection(at time.Time) (bool, time.Duration) {
|
func (t *PCTransport) IsShortConnection(at time.Time) (bool, time.Duration) {
|
||||||
t.lock.RLock()
|
t.lock.RLock()
|
||||||
defer t.lock.RUnlock()
|
defer t.lock.RUnlock()
|
||||||
|
|
||||||
@@ -568,7 +568,7 @@ func (t *PCTransport) handleConnectionFailed(forceShortConn bool) {
|
|||||||
isShort := forceShortConn
|
isShort := forceShortConn
|
||||||
if !isShort {
|
if !isShort {
|
||||||
var duration time.Duration
|
var duration time.Duration
|
||||||
isShort, duration = t.isShortConnection(time.Now())
|
isShort, duration = t.IsShortConnection(time.Now())
|
||||||
if isShort {
|
if isShort {
|
||||||
pair, err := t.getSelectedPair()
|
pair, err := t.getSelectedPair()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -456,11 +456,31 @@ func (t *TransportManager) NegotiateSubscriber(force bool) {
|
|||||||
t.subscriber.Negotiate(force)
|
t.subscriber.Negotiate(force)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TransportManager) ICERestart(iceConfig *livekit.ICEConfig, resetShortConnection bool) {
|
func (t *TransportManager) ICERestart(iceConfig *livekit.ICEConfig, reason livekit.ReconnectReason) {
|
||||||
if iceConfig != nil {
|
if iceConfig != nil {
|
||||||
t.SetICEConfig(iceConfig)
|
t.SetICEConfig(iceConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
isShort bool
|
||||||
|
duration time.Duration
|
||||||
|
resetShortConnection bool
|
||||||
|
)
|
||||||
|
switch reason {
|
||||||
|
case livekit.ReconnectReason_RR_PUBLISHER_FAILED:
|
||||||
|
resetShortConnection = true
|
||||||
|
isShort, duration = t.publisher.IsShortConnection(time.Now())
|
||||||
|
|
||||||
|
case livekit.ReconnectReason_RR_SUBSCRIBER_FAILED:
|
||||||
|
resetShortConnection = true
|
||||||
|
isShort, duration = t.subscriber.IsShortConnection(time.Now())
|
||||||
|
}
|
||||||
|
|
||||||
|
if isShort {
|
||||||
|
t.params.Logger.Infow("short connection by client ice restart", "duration", duration, "reason", reason)
|
||||||
|
t.handleConnectionFailed(isShort)
|
||||||
|
}
|
||||||
|
|
||||||
if resetShortConnection {
|
if resetShortConnection {
|
||||||
t.publisher.ResetShortConnOnICERestart()
|
t.publisher.ResetShortConnOnICERestart()
|
||||||
t.subscriber.ResetShortConnOnICERestart()
|
t.subscriber.ResetShortConnOnICERestart()
|
||||||
|
|||||||
Reference in New Issue
Block a user