From 294bcf62857528358f3f05d88062cca3ae275c9c Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 24 Feb 2024 10:39:37 -0500 Subject: [PATCH 1/2] fix: catch ws errors --- packages/server/src/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index 311012a..0faa14e 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -51,6 +51,10 @@ process process.exit(); }); +wssDevice.on('error', (err) => { + log.error(`Device: ${err}`); +}); + wssDevice.on('connection', (ws, req) => { if (config.deviceListener.secret) { if (config.deviceListener.secret != req.headers['x-rotom-secret']) { @@ -224,6 +228,10 @@ function identifyControlChannelFromWorkerId(workerId: string): string | null { return null; } +wssController.on('error', (err) => { + log.error(`CONTROLLER: ${err}`); +}); + wssController.on('connection', (ws, req) => { if (config.controllerListener.secret) { if (config.controllerListener.secret != req.headers['x-rotom-secret']) { From b5ea4487114685de61c5d763a28f3d0784f10e3a Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 24 Feb 2024 10:46:48 -0500 Subject: [PATCH 2/2] fix: capture connection errors too --- packages/server/src/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index 0faa14e..b59257b 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -52,10 +52,13 @@ process }); wssDevice.on('error', (err) => { - log.error(`Device: ${err}`); + log.error(`Device websocket error:`, err); }); wssDevice.on('connection', (ws, req) => { + ws.on('error', (err) => { + log.error(`Device connection error:`, err); + }); if (config.deviceListener.secret) { if (config.deviceListener.secret != req.headers['x-rotom-secret']) { log.info(`Device: New connection from ${req.socket.remoteAddress} url ${req.url} - incorrect secret, rejecting`); @@ -229,10 +232,13 @@ function identifyControlChannelFromWorkerId(workerId: string): string | null { } wssController.on('error', (err) => { - log.error(`CONTROLLER: ${err}`); + log.error(`CONTROLLER websocket error:`, err); }); wssController.on('connection', (ws, req) => { + ws.on('error', (err) => { + log.error(`CONTROLLER connection error:`, err); + }); if (config.controllerListener.secret) { if (config.controllerListener.secret != req.headers['x-rotom-secret']) { log.info(`CONTROLLER: New connection from ${req.socket.remoteAddress} - incorrect secret, rejecting`);