Skip to content

Commit

Permalink
Add ice disconnected timeout (#1746)
Browse files Browse the repository at this point in the history
  • Loading branch information
lodoyun authored Aug 31, 2021
1 parent c60fb3b commit 6aaf5c1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions erizo_controller/erizoClient/src/ErizoConnectionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ let ErizoSessionId = 103;
const QUALITY_LEVEL_GOOD = 'good';
const QUALITY_LEVEL_LOW_PACKET_LOSSES = 'low-packet-losses';
const QUALITY_LEVEL_HIGH_PACKET_LOSSES = 'high-packet-losses';
const ICE_DISCONNECTED_TIMEOUT = 2000;

const QUALITY_LEVELS = [
QUALITY_LEVEL_HIGH_PACKET_LOSSES,
Expand Down Expand Up @@ -98,6 +99,15 @@ class ErizoConnection extends EventEmitterConst {
if (['completed', 'connected'].indexOf(state) !== -1) {
this.wasAbleToConnect = true;
}
if (state === 'disconnected' && this.wasAbleToConnect && !this.disableIceRestart) {
log.warning(`messsage: ICE Disconnected, start timeout to reload ice, ${this.toLog()}`);
setTimeout(() => {
if (this.stack.peerConnection.iceConnectionState === 'disconnected') {
log.warning(`message: ICE Disconnected timeout, restarting ICE, ${this.toLog()}`);
this.stack.restartIce();
}
}, ICE_DISCONNECTED_TIMEOUT);
}
if (state === 'failed' && this.wasAbleToConnect && !this.disableIceRestart) {
log.warning(`message: Restarting ICE, ${this.toLog()}`);
this.stack.restartIce();
Expand Down

0 comments on commit 6aaf5c1

Please sign in to comment.