Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket.IO with uWebSockets: "initial_headers" event not being emitted #5300

Open
AKibMg opened this issue Feb 18, 2025 · 0 comments
Open

Socket.IO with uWebSockets: "initial_headers" event not being emitted #5300

AKibMg opened this issue Feb 18, 2025 · 0 comments
Labels
to triage Waiting to be triaged by a member of the team

Comments

@AKibMg
Copy link

AKibMg commented Feb 18, 2025

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".

@AKibMg AKibMg added the to triage Waiting to be triaged by a member of the team label Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to triage Waiting to be triaged by a member of the team
Projects
None yet
Development

No branches or pull requests

1 participant