diff --git a/src/node/routes/health.ts b/src/node/routes/health.ts index f38bb0ab..faf1f9c7 100644 --- a/src/node/routes/health.ts +++ b/src/node/routes/health.ts @@ -13,8 +13,8 @@ router.get("/", (req, res) => { export const wsRouter = WsRouter() wsRouter.ws("/", async (req) => { - wss.handleUpgrade(req, req.socket, req.head, (ws) => { - ws.on("message", () => { + wss.handleUpgrade(req, req.ws, req.head, (ws) => { + ws.addEventListener("message", () => { ws.send( JSON.stringify({ event: "health", @@ -23,5 +23,6 @@ wsRouter.ws("/", async (req) => { }), ) }) + req.ws.resume() }) }) diff --git a/test/test-plugin/src/index.ts b/test/test-plugin/src/index.ts index 592ad372..772b59d8 100644 --- a/test/test-plugin/src/index.ts +++ b/test/test-plugin/src/index.ts @@ -28,7 +28,8 @@ export const plugin: cs.Plugin = { wsRouter() { const wr = cs.WsRouter() wr.ws("/test-app", (req) => { - cs.wss.handleUpgrade(req, req.socket, req.head, (ws) => { + cs.wss.handleUpgrade(req, req.ws, req.head, (ws) => { + req.ws.resume() ws.send("hello") }) })