Update
This commit is contained in:
parent
21cb42ebc0
commit
a4163a1cb5
|
|
@ -411,6 +411,7 @@ export class WebSocketIo {
|
||||||
// Kết nối tới station qua Telnet / Socket
|
// Kết nối tới station qua Telnet / Socket
|
||||||
const client = new net.Socket()
|
const client = new net.Socket()
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
|
client.setTimeout(5000)
|
||||||
client.connect(station.port, station.ip, async () => {
|
client.connect(station.port, station.ip, async () => {
|
||||||
console.log(
|
console.log(
|
||||||
`Connected to station ${station.name} (${station.ip}) to clear line ${clearLine}`
|
`Connected to station ${station.name} (${station.ip}) to clear line ${clearLine}`
|
||||||
|
|
@ -432,11 +433,17 @@ export class WebSocketIo {
|
||||||
|
|
||||||
client.on('error', (err) => {
|
client.on('error', (err) => {
|
||||||
console.error(`Error clearing line ${clearLine}:`, err)
|
console.error(`Error clearing line ${clearLine}:`, err)
|
||||||
reject(err)
|
resolve()
|
||||||
})
|
})
|
||||||
|
|
||||||
client.on('close', () => {
|
client.on('close', () => {
|
||||||
console.log(`Station connection closed (line ${clearLine})`)
|
console.log(`Station connection closed (line ${clearLine})`)
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
client.on('timeout', () => {
|
||||||
|
console.log(`Station connection timeout (line ${clearLine})`)
|
||||||
|
client.destroy()
|
||||||
|
resolve()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue