Merge pull request #8383 from capilkey/listenonly-logging-imp

Listen only logging improvements
This commit is contained in:
Anton Georgiev 2019-12-03 09:21:49 -05:00 committed by GitHub
commit 8c36a94565
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 31 deletions

View File

@ -41,7 +41,14 @@ export default class KurentoAudioBridge extends BaseAudioBridge {
static normalizeError(error = {}) { static normalizeError(error = {}) {
const errorMessage = error.name || error.message || error.reason || 'Unknown error'; const errorMessage = error.name || error.message || error.reason || 'Unknown error';
const errorCode = error.code || undefined; 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 }; return { errorMessage, errorCode, errorReason };
} }
@ -132,6 +139,7 @@ export default class KurentoAudioBridge extends BaseAudioBridge {
this.callback({ this.callback({
status: this.baseCallStates.failed, status: this.baseCallStates.failed,
error: this.baseErrorCodes.CONNECTION_ERROR, error: this.baseErrorCodes.CONNECTION_ERROR,
bridgeError: 'No WebRTC Peer',
}); });
} }
@ -143,13 +151,14 @@ export default class KurentoAudioBridge extends BaseAudioBridge {
const onFail = (error) => { const onFail = (error) => {
const { errorMessage, errorCode, errorReason } = KurentoAudioBridge.normalizeError(error); const { errorMessage, errorCode, errorReason } = KurentoAudioBridge.normalizeError(error);
// Listen only connected successfully already and dropped mid-call. // Listen only connected successfully already and dropped mid-call.
// Try to reconnect ONCE (binded to reconnectOngoing flag) // Try to reconnect ONCE (binded to reconnectOngoing flag)
if (this.hasSuccessfullyStarted && !this.reconnectOngoing) { if (this.hasSuccessfullyStarted && !this.reconnectOngoing) {
logger.error({ logger.error({
logCode: 'listenonly_error_try_to_reconnect', logCode: 'listenonly_error_try_to_reconnect',
extraInfo: { errorMessage, errorCode, errorReason }, 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(); window.kurentoExitAudio();
this.callback({ status: this.baseCallStates.reconnecting }); this.callback({ status: this.baseCallStates.reconnecting });
this.reconnectOngoing = true; this.reconnectOngoing = true;
@ -160,6 +169,7 @@ export default class KurentoAudioBridge extends BaseAudioBridge {
this.callback({ this.callback({
status: this.baseCallStates.failed, status: this.baseCallStates.failed,
error: this.baseErrorCodes.CONNECTION_ERROR, error: this.baseErrorCodes.CONNECTION_ERROR,
bridgeError: 'Reconnect Timeout',
}); });
this.reconnectOngoing = false; this.reconnectOngoing = false;
this.hasSuccessfullyStarted = false; this.hasSuccessfullyStarted = false;
@ -181,12 +191,12 @@ export default class KurentoAudioBridge extends BaseAudioBridge {
logger.error({ logger.error({
logCode: 'listenonly_error_failed_to_connect', logCode: 'listenonly_error_failed_to_connect',
extraInfo: { errorMessage, errorCode, errorReason }, 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 { } else {
logger.error({ logger.error({
logCode: 'listenonly_error_reconnect_failed', logCode: 'listenonly_error_reconnect_failed',
extraInfo: { errorMessage, errorCode, errorReason }, 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; this.reconnectOngoing = false;

View File

@ -5,7 +5,6 @@ import VoiceUsers from '/imports/api/voice-users';
import SIPBridge from '/imports/api/audio/client/bridge/sip'; import SIPBridge from '/imports/api/audio/client/bridge/sip';
import logger from '/imports/startup/client/logger'; import logger from '/imports/startup/client/logger';
import { notify } from '/imports/ui/services/notification'; import { notify } from '/imports/ui/services/notification';
import browser from 'browser-detect';
import playAndRetry from '/imports/utils/mediaElementPlayRetry'; import playAndRetry from '/imports/utils/mediaElementPlayRetry';
import iosWebviewAudioPolyfills from '/imports/utils/ios-webview-audio-polyfills'; import iosWebviewAudioPolyfills from '/imports/utils/ios-webview-audio-polyfills';
import { tryGenerateIceCandidates } from '/imports/utils/safari-webrtc'; import { tryGenerateIceCandidates } from '/imports/utils/safari-webrtc';
@ -15,6 +14,7 @@ const MEDIA = Meteor.settings.public.media;
const MEDIA_TAG = MEDIA.mediaTag; const MEDIA_TAG = MEDIA.mediaTag;
const ECHO_TEST_NUMBER = MEDIA.echoTestNumber; const ECHO_TEST_NUMBER = MEDIA.echoTestNumber;
const MAX_LISTEN_ONLY_RETRIES = 1; const MAX_LISTEN_ONLY_RETRIES = 1;
const LISTEN_ONLY_CALL_TIMEOUT_MS = 15000;
const CALL_STATES = { const CALL_STATES = {
STARTED: 'started', STARTED: 'started',
@ -153,7 +153,6 @@ class AudioManager {
this.isListenOnly = true; this.isListenOnly = true;
this.isEchoTest = false; this.isEchoTest = false;
const { name } = browser();
// The kurento bridge isn't a full audio bridge yet, so we have to differ it // The kurento bridge isn't a full audio bridge yet, so we have to differ it
const bridge = this.useKurento ? this.listenOnlyBridge : this.bridge; 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 // 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) => { const iceGatheringTimeout = new Promise((resolve, reject) => {
setTimeout(reject, 12000, iceGatheringErr); setTimeout(reject, LISTEN_ONLY_CALL_TIMEOUT_MS, listenOnlyCallTimeoutErr);
}); });
const handleListenOnlyError = async (err) => { const exitKurentoAudio = () => {
const error = { if (this.useKurento) {
type: 'MEDIA_ERROR', window.kurentoExitAudio();
message: this.messages.error.MEDIA_ERROR, const audio = document.querySelector(MEDIA_TAG);
}; audio.muted = false;
}
};
const handleListenOnlyError = (err) => {
if (iceGatheringTimeout) { if (iceGatheringTimeout) {
clearTimeout(iceGatheringTimeout); clearTimeout(iceGatheringTimeout);
} }
const errorReason = (typeof err === 'string' ? err : undefined) || err.errorReason || err.errorMessage;
const bridgeInUse = (this.useKurento ? 'Kurento' : 'SIP');
logger.error({ logger.error({
logCode: 'audiomanager_listenonly_error', logCode: 'audiomanager_listenonly_error',
extraInfo: { extraInfo: {
error: err, errorReason,
audioBridge: bridgeInUse,
retries, retries,
}, },
}, 'Listen only error'); }, `Listen only error - ${err} - bridge: ${bridgeInUse}`);
throw error;
}; };
logger.info({ logCode: 'audiomanager_join_listenonly', extraInfo: { logType: 'user_action' } }, 'user requested to connect to audio conference as listen only'); 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, iceGatheringTimeout,
])) ]))
.catch(async (err) => { .catch(async (err) => {
handleListenOnlyError(err);
if (retries < MAX_LISTEN_ONLY_RETRIES) { if (retries < MAX_LISTEN_ONLY_RETRIES) {
// Fallback to SIP.js listen only in case of failure // Fallback to SIP.js listen only in case of failure
if (this.useKurento) { if (this.useKurento) {
// Exit previous SFU session and clean audio tag state exitKurentoAudio();
window.kurentoExitAudio();
this.useKurento = false; 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;
retries += 1; this.joinListenOnly(retries);
await this.joinListenOnly(retries);
} catch (error) {
return handleListenOnlyError(error);
}
} else {
return handleListenOnlyError(err);
} }
return null; return null;
@ -310,7 +319,6 @@ class AudioManager {
this.isConnected = false; this.isConnected = false;
this.isConnecting = false; this.isConnecting = false;
this.isHangingUp = false; this.isHangingUp = false;
this.isListenOnly = false;
this.autoplayBlocked = false; this.autoplayBlocked = false;
this.failedMediaElements = []; this.failedMediaElements = [];
@ -364,7 +372,7 @@ class AudioManager {
errorCode: error, errorCode: error,
cause: bridgeError, cause: bridgeError,
}, },
}, `errorCode=${error}, cause=${bridgeError}`); }, `Audio error - errorCode=${error}, cause=${bridgeError}`);
if (silenceNotifications !== true) { if (silenceNotifications !== true) {
this.notify(errorMsg, true); this.notify(errorMsg, true);
this.exitAudio(); this.exitAudio();