Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

234
Views
How to access Express-style request objects when upgrading to websocket?

Using Express + ws (websocket) libraries.

"App" uses some Express middleware to add the current user to the request object, but WS gets a Node request object without the information I need.

How can I pass this data to the websocket when upgrading connection?

const server = http.createServer(app); // app is using the express middleware to add info I need

const wss: WebSocket.Server = new WebSocketService(clients, { noServer: true }).wss;

server.on('upgrade', (request, socket: any, head) => {
    wss.handleUpgrade(request, socket, head, (ws: WebSocket) => {
        wss.emit('connection', ws, request);
    });
});

server.listen(3000, () => {
    console.log('Listening on port 3000');
});
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!