From a4163a1cb5fadaf446f75ca3ed83ed213924a947 Mon Sep 17 00:00:00 2001 From: nguyentrungthat <80239428+nguentrungthat@users.noreply.github.com> Date: Wed, 5 Nov 2025 13:11:35 +0700 Subject: [PATCH] Update --- BACKEND/providers/socket_io_provider.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/BACKEND/providers/socket_io_provider.ts b/BACKEND/providers/socket_io_provider.ts index 3345d90..13c0a86 100644 --- a/BACKEND/providers/socket_io_provider.ts +++ b/BACKEND/providers/socket_io_provider.ts @@ -411,6 +411,7 @@ export class WebSocketIo { // Kết nối tới station qua Telnet / Socket const client = new net.Socket() return new Promise((resolve, reject) => { + client.setTimeout(5000) client.connect(station.port, station.ip, async () => { console.log( `Connected to station ${station.name} (${station.ip}) to clear line ${clearLine}` @@ -432,11 +433,17 @@ export class WebSocketIo { client.on('error', (err) => { console.error(`Error clearing line ${clearLine}:`, err) - reject(err) + resolve() }) client.on('close', () => { console.log(`Station connection closed (line ${clearLine})`) + resolve() + }) + client.on('timeout', () => { + console.log(`Station connection timeout (line ${clearLine})`) + client.destroy() + resolve() }) }) }