Skip to content

Commit

Permalink
Merge pull request #36 from UnownHash/ws-error-catching
Browse files Browse the repository at this point in the history
fix: catch ws errors
  • Loading branch information
Fabio1988 authored Nov 13, 2024
2 parents f8f389f + b5ea448 commit 2b9d935
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ process
process.exit();
});

wssDevice.on('error', (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 @@ -224,7 +231,14 @@ function identifyControlChannelFromWorkerId(workerId: string): string | null {
return null;
}

wssController.on('error', (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 2b9d935

Please sign in to comment.