From 359e2c62ca54cf41d70635a994ca748fcca50f14 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 13 Jul 2023 14:09:10 +0200 Subject: Handle websocket errors. --- server.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 65f5a7a..3fc6274 100644 --- a/server.js +++ b/server.js @@ -2364,6 +2364,11 @@ wss.on('connection', (socket, req) => { delete game_clients[socket.game_id] }) + socket.on('error', (err) => { + SLOG(socket, "ERROR" + err) + socket.close(1000, err.toString()) + }) + socket.on('message', (data) => { try { let [ cmd, arg ] = JSON.parse(data) @@ -2372,7 +2377,7 @@ wss.on('connection', (socket, req) => { else handle_observer_message(socket, cmd, arg) } catch (err) { - send_message(socket, 'error', err) + send_message(socket, 'error', err.toString()) } }) -- cgit v1.2.3