无法使用 ESL 从 freeswitch 检索持续时间

Unable to retrieve Duration from freeswitch using ESL

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

这是我执行点击通话时的代码,我用的是'originate command',这是我的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 的详细信息中不存在 'answered and end epoch'。

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

提前致谢!

为此 purpose.you 使用 CHANNEL_HANGUP_COMPLETE 事件:

它给出以下响应...

variable_billsec: 17

variable_billmsec: 16660

variable_billusec: 16660036

糟糕,我发现我没有订阅 FreeSWITCH 的 'events: all' 这就是为什么我只得到 CHANNEL_EXECUTE_COMPLETE.