【问题标题】:Unable to retrieve Duration from freeswitch using ESL无法使用 ESL 从 freeswitch 检索 Duration
【发布时间】:2021-08-26 05:58:55
【问题描述】:

我是 FreeSWITCH 的新手,我正在尝试在我的 NodeJs 应用程序中应用点击通话。

这是我执行点击通话时的代码,我使用“发起命令”,这是我的reference

 let app_args = `sofia/gateway/fs-test1/${phoneNumberFrom}`;
 let arg1 = `{ignore_early_media=true,origination_caller_id_number=${callerId}}${app_args}`;
 let arg2 = `${arg1} &bridge({origination_caller_id_number=${callerId}}sofia/gateway/fs-test3/${phoneNumberTo})`;

  connection.api('originate', arg2, function (res) {
      callUid = res.getBody().toString().replace('+OK ', '');
  });

它工作得很好,但我想在两个通话结束时获得通话时长。 我按照here 中的说明计算了持续时间, 所以在我的 nodejs 代码中是这样的:

const answer_epoch = fsEvent.getHeader('variable_answer_epoch');
const end_epoch = fsEvent.getHeader('variable_end_epoch');

  private calculateDuration(start_epoch:any, end_epoch: any):any{
        const answeredDate = new Date(start_epoch*1000);
        const hangupDate = new Date(end_epoch*1000);

        console.log('Answered Time -> ', answeredDate.toUTCString());
        console.log('HangupTime ->' , hangupDate.toUTCString());

        let duration = Math.abs(answeredDate.getTime() - hangupDate.getTime());

        return duration;
    }

所以我使用 ESL 监听来自 FreeSWITCH 的事件,并监听名为“CHANNEL_EXECUTE_COMPLETE”的特定事件,因为它是在此api originate 期间引发的唯一事件,并且我检索了此事件的记录,但 CHANNEL_EXECUTE_COMPLETE 的详细信息中不存在“已回答并结束的时代”。

有谁知道使用 ESL 从 FreeSWITCH 检索通话时长的另一种方法是什么?

提前致谢!

【问题讨论】:

    标签: node.js freeswitch


    【解决方案1】:

    为此目的使用 CHANNEL_HANGUP_COMPLETE 事件。你:

    它给出以下响应...

    variable_billsec: 17

    variable_billmsec: 16660

    variable_billusec: 16660036

    【讨论】:

    • 是的,我已经这样做了,我尝试收听该事件,但我不确定为什么没有为“CHANNEL_HANGUP_COMPLETE”引发事件,这就是我努力获取 variable_billsec 的原因。跨度>
    • 您使用的是哪个 FreeSWITCH 版本?
    • FreeSWITCH 版本:1.10.6
    • 您是否使用“CHANNEL_HANGUP”事件?如果没有,请尝试一下
    • 您可以将开始时间和挂机时间存储在数据库中以进行计算...我想到了 FreeSWITCH 心跳功能
    【解决方案2】:

    我的错,我发现我没有订阅 FreeSWITCH 的“事件:全部”,这就是为什么我只得到 CHANNEL_EXECUTE_COMPLETE。

    【讨论】:

      猜你喜欢
      • 2014-03-23
      • 2015-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多