From 990d0a7bca505b5342c012a7015509506c8b59e1 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Sun, 22 Jan 2023 12:46:20 -0500 Subject: [PATCH] when closing websocket at end of call send ws code 1000 --- lib/tasks/hangup.js | 1 + lib/utils/ws-requestor.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/tasks/hangup.js b/lib/tasks/hangup.js index 076091fe..1506e2ce 100644 --- a/lib/tasks/hangup.js +++ b/lib/tasks/hangup.js @@ -18,6 +18,7 @@ class TaskHangup extends Task { await super.exec(cs); try { await dlg.destroy({headers: this.headers}); + cs._callReleased(); } catch (err) { this.logger.error(err, 'TaskHangup:exec - Error hanging up call'); } diff --git a/lib/utils/ws-requestor.js b/lib/utils/ws-requestor.js index 16a439ee..81697e45 100644 --- a/lib/utils/ws-requestor.js +++ b/lib/utils/ws-requestor.js @@ -165,8 +165,9 @@ class WsRequestor extends BaseRequestor { this.logger.debug('WsRequestor:close closing socket'); try { if (this.ws) { - this.ws.close(); + this.ws.close(1000); this.ws.removeAllListeners(); + this.ws = null; } for (const [msgid, obj] of this.messagesInFlight) {