From 5596f69114455007bc8c32b81e23a65ea577b137 Mon Sep 17 00:00:00 2001 From: killer069 <65385476+killer069@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:21:21 +0530 Subject: [PATCH] Socket Close Error Fixed --- play-dl/YouTube/classes/LiveStream.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/play-dl/YouTube/classes/LiveStream.ts b/play-dl/YouTube/classes/LiveStream.ts index 1cf5e16..85cee36 100644 --- a/play-dl/YouTube/classes/LiveStream.ts +++ b/play-dl/YouTube/classes/LiveStream.ts @@ -174,14 +174,19 @@ export class Stream { this.per_sec_bytes = 0 this.timer = null this.socket = null + this.stream.on('close', () => { + this.cleanup() + }) this.duration = duration; (duration > 300) ? this.loop_start() : this.normal_start() } private cleanup(){ clearTimeout(this.timer as NodeJS.Timer) - this.socket?.destroy() - this.socket = null + this.socket?.end() + this.socket?.on('close', () => { + console.log('Socket Closed') + }) this.timer = null this.url = '' this.bytes_count = 0