mirror of
https://github.com/jetkvm/cloud-api.git
synced 2025-09-16 08:38:15 +00:00
Enhance WebSocket close event logging to include closure code and reason
This commit is contained in:
parent
8d9fbe3ef4
commit
bcac909523
@ -172,16 +172,18 @@ function setupDeviceWebSocket(deviceWs: WebSocket, device: Device, req: Incoming
|
|||||||
await cleanup();
|
await cleanup();
|
||||||
});
|
});
|
||||||
|
|
||||||
deviceWs.on("close", async () => {
|
deviceWs.on("close", async (code, reason) => {
|
||||||
console.log(`[Device] Connection closed for ${id}`);
|
console.log(
|
||||||
|
`[Device] Connection closed for ${id} with code ${code} and reason ${reason}`,
|
||||||
|
);
|
||||||
await cleanup();
|
await cleanup();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Cleanup function
|
// Cleanup function
|
||||||
async function cleanup() {
|
async function cleanup() {
|
||||||
|
console.log(`[Device] Cleanup for ${id}`);
|
||||||
activeConnections.delete(id);
|
activeConnections.delete(id);
|
||||||
clearInterval(checkAliveInterval);
|
clearInterval(checkAliveInterval);
|
||||||
console.log(`[Device] Cleanup for ${id}`);
|
|
||||||
await updateDeviceLastSeen(id);
|
await updateDeviceLastSeen(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user