From a4fab626ed2701c400931b0500d6b6697e75722a Mon Sep 17 00:00:00 2001 From: Matt Preskett Date: Thu, 17 Aug 2023 13:43:35 +0100 Subject: [PATCH 1/2] Update _onFeatureServerTransfer to fix REFER case --- lib/call-session.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/call-session.js b/lib/call-session.js index 366b8b3..e60eae6 100644 --- a/lib/call-session.js +++ b/lib/call-session.js @@ -913,19 +913,22 @@ Duration=${payload.duration} ` uac.other.destroy(); this.srf.endSession(this.req); }); - // now we can destroy the old dialog - dlg.destroy().catch(() => {}); - // modify rtpengine to stream to new feature server - const opts = Object.assign({sdp: uac.remote.sdp, 'to-tag': res.getParsedHeader('To').params.tag}, - this.rtpEngineOpts.answer); + const opts = { + ...this.rtpEngineOpts.common, + 'from-tag': this.rtpEngineOpts.uas.tag, + 'to-tag': this.rtpEngineOpts.uac.tag, + sdp: uac.remote.sdp, + flags: ['port latching'] + }; const response = await this.answer(opts); if ('ok' !== response.result) { - res.send(488); - throw new Error(`_onFeatureServerTransfer: rtpengine failed: ${JSON.stringify(response)}`); + throw new Error(`_onFeatureServerTransfer: rtpengine answer failed: ${JSON.stringify(response)}`); } + dlg.destroy().catch(() => {}); this.logger.info('successfully moved call to new feature server'); } catch (err) { + res.send(488); this.logger.error(err, 'Error handling refer from feature server'); } } From 8ebca75083f59c8caef148ce6f74043666fa8ead Mon Sep 17 00:00:00 2001 From: Matt Preskett Date: Thu, 17 Aug 2023 16:21:08 +0100 Subject: [PATCH 2/2] Add INFO listener --- lib/call-session.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/call-session.js b/lib/call-session.js index e60eae6..9cf6f00 100644 --- a/lib/call-session.js +++ b/lib/call-session.js @@ -904,6 +904,7 @@ Duration=${payload.duration} ` this.uac = uac; uac.other = this.uas; this.uas.other = uac; + uac.on('info', this._onInfo.bind(this, uac)); uac.on('modify', this._onReinvite.bind(this, uac)); uac.on('refer', this._onFeatureServerTransfer.bind(this, uac)); uac.on('destroy', () => {