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

343
Views
WebSocket: no se puede conectar (HTTP esperado/)

Estoy usando Node.JS y estoy usando http para usar un servidor express en el que mi WebSocket está activado, pero cuando intento conectarme al socket, aparece el error 'HTTP esperado/'.

Error

Mi código:

 const express = require('express'); const app = express(); const server = require('http').createServer(app); app.get('/', (req, res) => { res.send("Hello World!"); }); const wss = new WebSocket.Server({ server }); // web socket stuff here server.listen(port, () => { console.log(`HTTP Server started on port ${port}`); });

Y luego, en otro proyecto de Node, tengo esto para conectar:

 const WebSocket = require('ws'); const ws = new WebSocket.WebSocket('ws://localhost:3000/ws');

¿Alguna ayuda?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

//my memory in this question was that const WebSocket = require('ws'); const socket = new WebSocket.Server({ port: 2424, host: "localhost"}); socket.on('connection', function(ws, wss) { var domain = wss.headers.origin; //etc...

Pero tal vez usted tiene un frente para comunicarse si no es la buena respuesta?

about 4 years ago · Juan Pablo Isaza Report
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!