io.engine undefined? #5376
Unanswered
SupertigerDev
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hi!
import { createServer } from "node:http";
import { Server } from "socket.io";
const httpServer = createServer();
const io = new Server(httpServer);
httpServer.on("upgrade", (req, socket, head) => {
if (req.url.startsWith("/socket.io/")) {
io.engine.handleUpgrade(req, socket, head);
} else {
socket.destroy();
}
});
httpServer.listen(3000); Reference: https://socket.io/docs/v4/server-api/#enginehandleupgraderequest-socket-head |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Am I being an idiot? why is io.engine undefined?
in the docs, it says i can use
io.engine.handleUpgrade
, butio.engine
seems to be undefined. vs code autosuggestion works tho, just when running the code it says undefinedhttps://stackblitz.com/edit/node-3y7mbxtu?file=index.js
v4.8.1
Beta Was this translation helpful? Give feedback.
All reactions