diff --git a/src/node/routes/index.ts b/src/node/routes/index.ts index 4d92c365..2c54917d 100644 --- a/src/node/routes/index.ts +++ b/src/node/routes/index.ts @@ -155,7 +155,7 @@ export const register = async ( const wsErrorHandler: express.ErrorRequestHandler = async (err, req) => { logger.error(`${err.message} ${err.stack}`) - ;(req as WebsocketRequest).ws.destroy(err) + ;(req as WebsocketRequest).ws.end() } wsApp.use(wsErrorHandler) diff --git a/src/node/wsRouter.ts b/src/node/wsRouter.ts index 1a057f0f..175f214a 100644 --- a/src/node/wsRouter.ts +++ b/src/node/wsRouter.ts @@ -5,8 +5,6 @@ import * as net from "net" export const handleUpgrade = (app: express.Express, server: http.Server): void => { server.on("upgrade", (req, socket, head) => { - socket.on("error", () => socket.destroy()) - req.ws = socket req.head = head req._ws_handled = false @@ -14,7 +12,7 @@ export const handleUpgrade = (app: express.Express, server: http.Server): void = // Send the request off to be handled by Express. ;(app as any).handle(req, new http.ServerResponse(req), () => { if (!req._ws_handled) { - socket.destroy(new Error("Not found")) + socket.end("HTTP/1.1 404 Not Found\r\n\r\n") } }) })