From 597f0739483b047d38b181cf1463db34005d1d27 Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Fri, 18 Dec 2020 17:33:58 +0530 Subject: [PATCH] Terminate connection on false pong --- src/WAConnection/3.Connect.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/WAConnection/3.Connect.ts b/src/WAConnection/3.Connect.ts index ce36e2f..848cf5d 100644 --- a/src/WAConnection/3.Connect.ts +++ b/src/WAConnection/3.Connect.ts @@ -211,6 +211,11 @@ export class WAConnection extends Base { if (anyTriggered) return if (this.state === 'open' && json[0] === 'Pong') { + if (!json[1]) { + this.closeInternal(DisconnectReason.close) + this.logger.info('Connection terminated by phone, closing...') + return + } if (this.phoneConnected !== json[1]) { this.phoneConnected = json[1] this.emit ('connection-phone-change', { connected: this.phoneConnected })