Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix connection failed event #1751

Merged
merged 3 commits into from
Sep 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions erizo_controller/erizoClient/src/ErizoConnectionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ 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 @@ -43,8 +42,8 @@ class ErizoConnection extends EventEmitterConst {

log.debug(`message: Building a new Connection, ${this.toLog()}`);
spec.onEnqueueingTimeout = (step) => {
const message = `reason: Timeout in ${step}`;
this.emit(ConnectionEvent({ type: 'connection-failed', connection: this, message }));
const message = `Timeout in ${step}`;
this._onConnectionFailed(message);
};

if (!spec.streamRemovedListener) {
Expand Down Expand Up @@ -99,15 +98,6 @@ 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 All @@ -122,6 +112,11 @@ class ErizoConnection extends EventEmitterConst {
return `connectionId: ${this.connectionId}, sessionId: ${this.sessionId}, qualityLevel: ${this.qualityLevel}, erizoId: ${this.erizoId}`;
}

_onConnectionFailed(message) {
log.warning(`Connection Failed, message: ${message}, ${this.toLog()}`);
this.emit(ConnectionEvent({ type: 'connection-failed', connection: this, message }));
}

close() {
log.debug(`message: Closing ErizoConnection, ${this.toLog()}`);
this.streamsMap.clear();
Expand Down Expand Up @@ -151,6 +146,11 @@ class ErizoConnection extends EventEmitterConst {
}

processSignalingMessage(msg) {
if (msg.type === 'failed') {
const message = 'Ice Connection failure detected in server';
this._onConnectionFailed(message);
return;
}
this.stack.processSignalingMessage(msg);
}

Expand Down