diff --git a/src/client-ws.ts b/src/client-ws.ts index 3550f0a..3f6658c 100644 --- a/src/client-ws.ts +++ b/src/client-ws.ts @@ -71,7 +71,7 @@ class ADNLClientWS extends ADNLClient { return undefined } - this.socket.close() + this.socket.destroySoon() } public write (data: Buffer | Uint8Array): void { diff --git a/src/client.ts b/src/client.ts index 7c78b55..5e88933 100644 --- a/src/client.ts +++ b/src/client.ts @@ -118,6 +118,10 @@ class ADNLClient extends EventEmitter { protected onClose (): void { this._state = ADNLClientState.CLOSED + if (!this.socket.destroyed) { + this.socket.destroy() + } + this.socket = null this.emit('close') } @@ -178,7 +182,7 @@ class ADNLClient extends EventEmitter { return undefined } - this.socket.end() + this.socket.destroySoon() } protected encrypt (data: Buffer): Buffer {