Don't switch candidate if signal closed when pc failed (#1498)
* Don't switch candidate if signal closed when pc failed * change comment * test case
This commit is contained in:
@@ -46,6 +46,7 @@ const (
|
||||
minTcpICEConnectTimeout = 5 * time.Second
|
||||
maxTcpICEConnectTimeout = 12 * time.Second // js-sdk has a default 15s timeout for first connection, let server detect failure earlier before that
|
||||
|
||||
minConnectTimeoutAfterICE = 10 * time.Second
|
||||
maxConnectTimeoutAfterICE = 20 * time.Second // max duration for waiting pc to connect after ICE is connected
|
||||
|
||||
shortConnectionThreshold = 90 * time.Second
|
||||
@@ -451,8 +452,7 @@ func (t *PCTransport) setICEConnectedAt(at time.Time) {
|
||||
|
||||
// set failure timer for dtls handshake
|
||||
iceDuration := at.Sub(t.iceStartedAt)
|
||||
// let ice has chance to become disconnected if user close/refresh client app before transport full connected.
|
||||
connTimeoutAfterICE := iceDisconnectedTimeout + time.Second + iceDuration
|
||||
connTimeoutAfterICE := minConnectTimeoutAfterICE
|
||||
if connTimeoutAfterICE < 3*iceDuration {
|
||||
connTimeoutAfterICE = 3 * iceDuration
|
||||
}
|
||||
@@ -462,10 +462,8 @@ func (t *PCTransport) setICEConnectedAt(at time.Time) {
|
||||
t.params.Logger.Debugw("setting connection timer after ice connected", "timeout", connTimeoutAfterICE, "iceDuration", iceDuration)
|
||||
t.connectAfterICETimer = time.AfterFunc(connTimeoutAfterICE, func() {
|
||||
state := t.pc.ConnectionState()
|
||||
iceState := t.pc.ICEConnectionState()
|
||||
// if ice connected, pc is still checking or connected but not fully established after timeout, then fire connection fail
|
||||
if iceState == webrtc.ICEConnectionStateConnected && state != webrtc.PeerConnectionStateClosed &&
|
||||
state != webrtc.PeerConnectionStateFailed && !t.isFullyEstablished() {
|
||||
// if pc is still checking or connected but not fully established after timeout, then fire connection fail
|
||||
if state != webrtc.PeerConnectionStateClosed && state != webrtc.PeerConnectionStateFailed && !t.isFullyEstablished() {
|
||||
t.params.Logger.Infow("connect timeout after ICE connected", "timeout", connTimeoutAfterICE, "iceDuration", iceDuration)
|
||||
t.handleConnectionFailed(false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user