socket.io
socket.io copied to clipboard
Socket.IO with uWebSockets: "initial_headers" event not being emitted
Describe the bug Seems like the "initial_headers" (and also "headers") event is never emitted when using Socket.IO with uWebSockets. Need a way to attach headers to the http handshake response.
To Reproduce socket.io v4.8.1 uWebSockets.js v20.51.0
Server
server.mjs
import { App } from "uWebSockets.js";
import { Server } from "socket.io";
const app = new App();
const io = new Server({
serveClient: false,
transports: ["websocket"],
});
io.attachApp(app);
io.engine.on("initial_headers", (headers, req) => {
console.log("initial headers event emitted");
});
io.on("connection", (socket) => {
console.log("connected");
});
app.listen(3000, (token) => {
if (token) {
console.log("Server listening on port 3000");
} else {
console.log("Failed to listen on port 3000");
}
});
Client
const socket = io("http://localhost:3000", {
transports: ["websocket"],
reconnection: true,
});
Expected behavior Expecting console to log "initial headers event emitted", but only getting "connected" and "Server listening on port 3000".