diff --git a/lib/utils/install-srf-locals.js b/lib/utils/install-srf-locals.js index aa8cd489..44acde9d 100644 --- a/lib/utils/install-srf-locals.js +++ b/lib/utils/install-srf-locals.js @@ -53,8 +53,9 @@ function installSrfLocals(srf, logger) { // retry to connect to any that were initially offline setInterval(async() => { for (const val of mediaservers) { - if (val.connect === 0) { + if (val.connects === 0) { try { + logger.info({mediaserver: val.opts}, 'Retrying initial connection to media server'); const ms = await mrf.connect(val.opts); val.ms = ms; } catch (err) { @@ -66,13 +67,15 @@ function installSrfLocals(srf, logger) { // if we have a single freeswitch (as is typical) report stats periodically if (mediaservers.length === 1) { - const ms = mediaservers[0].ms; setInterval(() => { try { - stats.gauge('fs.media.channels.in_use', ms.currentSessions); - stats.gauge('fs.media.channels.free', ms.maxSessions - ms.currentSessions); - stats.gauge('fs.media.calls_per_second', ms.cps); - stats.gauge('fs.media.cpu_idle', ms.cpuIdle); + if (mediaservers[0].ms && mediaservers[0].active) { + const ms = mediaservers[0].ms; + stats.gauge('fs.media.channels.in_use', ms.currentSessions); + stats.gauge('fs.media.channels.free', ms.maxSessions - ms.currentSessions); + stats.gauge('fs.media.calls_per_second', ms.cps); + stats.gauge('fs.media.cpu_idle', ms.cpuIdle); + } } catch (err) { logger.info(err, 'Error sending media server metrics');