Merge pull request #10741 from mariogasparoni/v2.2.x-release

Properly stops userAgent / peer when audio connection/reconnection fails
This commit is contained in:
Anton Georgiev 2020-10-28 14:13:14 -04:00 committed by GitHub
commit b17f54283a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,7 +27,7 @@ const IPV4_FALLBACK_DOMAIN = Meteor.settings.public.app.ipv4FallbackDomain;
const CALL_CONNECT_TIMEOUT = 20000;
const ICE_NEGOTIATION_TIMEOUT = 20000;
const AUDIO_SESSION_NUM_KEY = 'AudioSessionNumber';
const USER_AGENT_RECONNECTION_ATTEMPTS = 3;
const USER_AGENT_RECONNECTION_ATTEMPTS = 7;
const USER_AGENT_RECONNECTION_DELAY_MS = 5000;
const USER_AGENT_CONNECTION_TIMEOUT_MS = 5000;
const ICE_GATHERING_TIMEOUT = MEDIA.iceGatheringTimeout || 5000;
@ -310,15 +310,18 @@ class SIPSession {
});
}
onBeforeUnload() {
this.userRequestedHangup = true;
if (this.userAgent) {
stopUserAgent() {
if (this.userAgent && (typeof this.userAgent.stop === 'function')) {
return this.userAgent.stop();
}
return Promise.resolve();
}
onBeforeUnload() {
this.userRequestedHangup = true;
return this.stopUserAgent();
}
createUserAgent(iceServers) {
return new Promise((resolve, reject) => {
if (this.userRequestedHangup === true) reject();
@ -426,6 +429,9 @@ class SIPSession {
error = 1002;
bridgeError = 'Websocket failed to connect';
}
this.stopUserAgent();
this.callback({
status: this.baseCallStates.failed,
error,
@ -463,6 +469,8 @@ class SIPSession {
if (code === 1006) {
this.stopUserAgent();
this.callback({
status: this.baseCallStates.failed,
error: 1006,
@ -483,6 +491,8 @@ class SIPSession {
resolve();
}).catch(() => {
this.stopUserAgent();
logger.info({
logCode: 'sip_js_session_ua_disconnected',
extraInfo: {
@ -521,6 +531,13 @@ class SIPSession {
this._reconnecting = true;
logger.info({
logCode: 'sip_js_session_ua_reconnection_attempt',
extraInfo: {
callerIdName: this.user.callerIdName,
},
}, `User agent reconnection attempt ${attempts}`);
setTimeout(() => {
this.userAgent.reconnect().then(() => {
this._reconnecting = false;