Catching websocket errors to not take down whole process
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Fabian Stamm 2020-08-16 12:33:16 +02:00
parent c2cea4c15a
commit b3465ea96d

View File

@ -22,6 +22,12 @@ export class WebsocketConnectionManager {
private static async onConnection(socket: WebSocket, req: IncomingMessage) { private static async onConnection(socket: WebSocket, req: IncomingMessage) {
Logging.log("New Connection:"); Logging.log("New Connection:");
socket.on("error", (err) => {
Logging.error(err);
socket.close();
});
const sendError = (error: string) => const sendError = (error: string) =>
socket.send(JSON.stringify({ ns: "error_msg", data: error })); socket.send(JSON.stringify({ ns: "error_msg", data: error }));