Merge pull request #8389 from capilkey/listenonly-logging-imp
Listen only logging improvements (2.2 version)
This commit is contained in:
commit
972b556452
@ -41,7 +41,14 @@ export default class KurentoAudioBridge extends BaseAudioBridge {
|
||||
static normalizeError(error = {}) {
|
||||
const errorMessage = error.name || error.message || error.reason || 'Unknown error';
|
||||
const errorCode = error.code || undefined;
|
||||
const errorReason = error.reason || error.id || 'Undefined reason';
|
||||
let errorReason = error.reason || error.id || 'Undefined reason';
|
||||
|
||||
// HOPEFULLY TEMPORARY
|
||||
// The errors are often just strings so replace the errorReason if that's the case
|
||||
if (typeof error === 'string') {
|
||||
errorReason = error;
|
||||
}
|
||||
// END OF HOPEFULLY TEMPORARY
|
||||
|
||||
return { errorMessage, errorCode, errorReason };
|
||||
}
|
||||
@ -132,6 +139,7 @@ export default class KurentoAudioBridge extends BaseAudioBridge {
|
||||
this.callback({
|
||||
status: this.baseCallStates.failed,
|
||||
error: this.baseErrorCodes.CONNECTION_ERROR,
|
||||
bridgeError: 'No WebRTC Peer',
|
||||
});
|
||||
}
|
||||
|
||||
@ -143,13 +151,14 @@ export default class KurentoAudioBridge extends BaseAudioBridge {
|
||||
|
||||
const onFail = (error) => {
|
||||
const { errorMessage, errorCode, errorReason } = KurentoAudioBridge.normalizeError(error);
|
||||
|
||||
// Listen only connected successfully already and dropped mid-call.
|
||||
// Try to reconnect ONCE (binded to reconnectOngoing flag)
|
||||
if (this.hasSuccessfullyStarted && !this.reconnectOngoing) {
|
||||
logger.error({
|
||||
logCode: 'listenonly_error_try_to_reconnect',
|
||||
extraInfo: { errorMessage, errorCode, errorReason },
|
||||
}, 'Listen only failed for an ongoing session, try to reconnect');
|
||||
}, `Listen only failed for an ongoing session, try to reconnect. - reason: ${errorReason}`);
|
||||
window.kurentoExitAudio();
|
||||
this.callback({ status: this.baseCallStates.reconnecting });
|
||||
this.reconnectOngoing = true;
|
||||
@ -160,6 +169,7 @@ export default class KurentoAudioBridge extends BaseAudioBridge {
|
||||
this.callback({
|
||||
status: this.baseCallStates.failed,
|
||||
error: this.baseErrorCodes.CONNECTION_ERROR,
|
||||
bridgeError: 'Reconnect Timeout',
|
||||
});
|
||||
this.reconnectOngoing = false;
|
||||
this.hasSuccessfullyStarted = false;
|
||||
@ -181,12 +191,12 @@ export default class KurentoAudioBridge extends BaseAudioBridge {
|
||||
logger.error({
|
||||
logCode: 'listenonly_error_failed_to_connect',
|
||||
extraInfo: { errorMessage, errorCode, errorReason },
|
||||
}, `Listen only failed when trying to start due to ${errorMessage}`);
|
||||
}, `Listen only failed when trying to start due to ${errorReason}`);
|
||||
} else {
|
||||
logger.error({
|
||||
logCode: 'listenonly_error_reconnect_failed',
|
||||
extraInfo: { errorMessage, errorCode, errorReason },
|
||||
}, `Listen only failed when trying to reconnect due to ${errorMessage}`);
|
||||
}, `Listen only failed when trying to reconnect due to ${errorReason}`);
|
||||
}
|
||||
|
||||
this.reconnectOngoing = false;
|
||||
|
@ -5,7 +5,6 @@ import VoiceUsers from '/imports/api/voice-users';
|
||||
import SIPBridge from '/imports/api/audio/client/bridge/sip';
|
||||
import logger from '/imports/startup/client/logger';
|
||||
import { notify } from '/imports/ui/services/notification';
|
||||
import browser from 'browser-detect';
|
||||
import playAndRetry from '/imports/utils/mediaElementPlayRetry';
|
||||
import iosWebviewAudioPolyfills from '/imports/utils/ios-webview-audio-polyfills';
|
||||
import { tryGenerateIceCandidates } from '/imports/utils/safari-webrtc';
|
||||
@ -15,6 +14,7 @@ const MEDIA = Meteor.settings.public.media;
|
||||
const MEDIA_TAG = MEDIA.mediaTag;
|
||||
const ECHO_TEST_NUMBER = MEDIA.echoTestNumber;
|
||||
const MAX_LISTEN_ONLY_RETRIES = 1;
|
||||
const LISTEN_ONLY_CALL_TIMEOUT_MS = 15000;
|
||||
|
||||
const CALL_STATES = {
|
||||
STARTED: 'started',
|
||||
@ -153,7 +153,6 @@ class AudioManager {
|
||||
this.isListenOnly = true;
|
||||
this.isEchoTest = false;
|
||||
|
||||
const { name } = browser();
|
||||
// The kurento bridge isn't a full audio bridge yet, so we have to differ it
|
||||
const bridge = this.useKurento ? this.listenOnlyBridge : this.bridge;
|
||||
|
||||
@ -185,30 +184,36 @@ class AudioManager {
|
||||
}
|
||||
|
||||
// We need this until we upgrade to SIP 9x. See #4690
|
||||
const iceGatheringErr = 'ICE_TIMEOUT';
|
||||
const listenOnlyCallTimeoutErr = this.useKurento ? 'KURENTO_CALL_TIMEOUT' : 'SIP_CALL_TIMEOUT';
|
||||
|
||||
const iceGatheringTimeout = new Promise((resolve, reject) => {
|
||||
setTimeout(reject, 12000, iceGatheringErr);
|
||||
setTimeout(reject, LISTEN_ONLY_CALL_TIMEOUT_MS, listenOnlyCallTimeoutErr);
|
||||
});
|
||||
|
||||
const handleListenOnlyError = async (err) => {
|
||||
const error = {
|
||||
type: 'MEDIA_ERROR',
|
||||
message: this.messages.error.MEDIA_ERROR,
|
||||
};
|
||||
const exitKurentoAudio = () => {
|
||||
if (this.useKurento) {
|
||||
window.kurentoExitAudio();
|
||||
const audio = document.querySelector(MEDIA_TAG);
|
||||
audio.muted = false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleListenOnlyError = (err) => {
|
||||
if (iceGatheringTimeout) {
|
||||
clearTimeout(iceGatheringTimeout);
|
||||
}
|
||||
|
||||
const errorReason = (typeof err === 'string' ? err : undefined) || err.errorReason || err.errorMessage;
|
||||
const bridgeInUse = (this.useKurento ? 'Kurento' : 'SIP');
|
||||
|
||||
logger.error({
|
||||
logCode: 'audiomanager_listenonly_error',
|
||||
extraInfo: {
|
||||
error: err,
|
||||
errorReason,
|
||||
audioBridge: bridgeInUse,
|
||||
retries,
|
||||
},
|
||||
}, 'Listen only error');
|
||||
|
||||
throw error;
|
||||
}, `Listen only error - ${err} - bridge: ${bridgeInUse}`);
|
||||
};
|
||||
|
||||
logger.info({ logCode: 'audiomanager_join_listenonly', extraInfo: { logType: 'user_action' } }, 'user requested to connect to audio conference as listen only');
|
||||
@ -221,24 +226,28 @@ class AudioManager {
|
||||
iceGatheringTimeout,
|
||||
]))
|
||||
.catch(async (err) => {
|
||||
handleListenOnlyError(err);
|
||||
|
||||
if (retries < MAX_LISTEN_ONLY_RETRIES) {
|
||||
// Fallback to SIP.js listen only in case of failure
|
||||
if (this.useKurento) {
|
||||
// Exit previous SFU session and clean audio tag state
|
||||
window.kurentoExitAudio();
|
||||
exitKurentoAudio();
|
||||
|
||||
this.useKurento = false;
|
||||
const audio = document.querySelector(MEDIA_TAG);
|
||||
audio.muted = false;
|
||||
|
||||
const errorReason = (typeof err === 'string' ? err : undefined) || err.errorReason || err.errorMessage;
|
||||
|
||||
logger.info({
|
||||
logCode: 'audiomanager_listenonly_fallback',
|
||||
extraInfo: {
|
||||
logType: 'fallback',
|
||||
errorReason,
|
||||
},
|
||||
}, `Falling back to FreeSWITCH listenOnly - cause: ${errorReason}`);
|
||||
}
|
||||
|
||||
try {
|
||||
retries += 1;
|
||||
await this.joinListenOnly(retries);
|
||||
} catch (error) {
|
||||
return handleListenOnlyError(error);
|
||||
}
|
||||
} else {
|
||||
return handleListenOnlyError(err);
|
||||
retries += 1;
|
||||
this.joinListenOnly(retries);
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -310,7 +319,6 @@ class AudioManager {
|
||||
this.isConnected = false;
|
||||
this.isConnecting = false;
|
||||
this.isHangingUp = false;
|
||||
this.isListenOnly = false;
|
||||
this.autoplayBlocked = false;
|
||||
this.failedMediaElements = [];
|
||||
|
||||
@ -364,7 +372,7 @@ class AudioManager {
|
||||
errorCode: error,
|
||||
cause: bridgeError,
|
||||
},
|
||||
}, `errorCode=${error}, cause=${bridgeError}`);
|
||||
}, `Audio error - errorCode=${error}, cause=${bridgeError}`);
|
||||
if (silenceNotifications !== true) {
|
||||
this.notify(errorMsg, true);
|
||||
this.exitAudio();
|
||||
|
Loading…
Reference in New Issue
Block a user