Skip to content

Commit

Permalink
fix: capture connection errors too
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtIeSocks authored and Fabio1988 committed Nov 13, 2024
1 parent b5017d6 commit 63d66dc
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down Expand Up @@ -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`);
Expand Down

0 comments on commit 63d66dc

Please sign in to comment.