fix freeswitch retry connection logic

This commit is contained in:
Dave Horton
2020-03-30 10:29:57 -04:00
parent b66c6627ed
commit 76bd88518a

View File

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