From 48b182c8911adbed67f26b8997cacbc50cd27338 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Tue, 1 Aug 2023 12:59:30 -0400 Subject: [PATCH] Fix/rest outdial failure session hangs (#411) * fix #410 * on rest outdial failure, if remote end closed gracefully don't wait for a reconnection --- lib/http-routes/api/create-call.js | 1 + lib/session/call-session.js | 18 +++++------------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/lib/http-routes/api/create-call.js b/lib/http-routes/api/create-call.js index 7f63b8f2..fc604c7f 100644 --- a/lib/http-routes/api/create-call.js +++ b/lib/http-routes/api/create-call.js @@ -258,6 +258,7 @@ router.post('/', async(req, res) => { sipStatus: err.status, sipReason: err.reason }); + cs.callGone = true; } else { if (cs) cs.emit('callStatusChange', { diff --git a/lib/session/call-session.js b/lib/session/call-session.js index aa0b6df7..745a8606 100644 --- a/lib/session/call-session.js +++ b/lib/session/call-session.js @@ -796,23 +796,15 @@ class CallSession extends Emitter { } } - if (0 === this.tasks.length && this.requestor instanceof WsRequestor && !this.callGone) { - //let span; + if (0 === this.tasks.length && + this.requestor instanceof WsRequestor && + !this.requestor.this.closedGracefully && + !this.callGone + ) { try { - //const {span} = this.rootSpan.startChildSpan('waiting for commands'); - //const {reason, queue, command} = await this._awaitCommandsOrHangup(); - /* - span.setAttributes({ - 'completion.reason': reason, - 'async.request.queue': queue, - 'async.request.command': command - }); - span.end(); - */ await this._awaitCommandsOrHangup(); if (this.callGone) break; } catch (err) { - //span.end(); this.logger.info(err, 'CallSession:exec - error waiting for new commands'); break; }