Closed samlior closed 1 year ago
Hi! The upgrade event was indeed missing from the documentation, this should be fixed now (https://github.com/socketio/engine.io/commit/535b068670848f6a3193528582484826a858d680).
how I should add some verification information in the upgrade request header, and reject the upgrade if the verification information is illegal.
You can manually handle the upgrade
event of the Node.js HTTP server:
import { createServer } from "http";
import { Server } from "socket.io";
const httpServer = createServer();
const io = new Server(httpServer);
httpServer.removeAllListeners("upgrade");
httpServer.on("upgrade", (req, socket, head) => {
// do some verification...
// then
io.engine.handleUpgrade(req, socket, head);
});
httpServer.listen(3000);
Thank you so much!
According to engine.io doc, it looks like the socket no longer emits the
upgrade
event, so it should be removed from this example.By the way, I would like to ask how I should add some verification information in the upgrade request header, and reject the upgrade if the verification information is illegal.