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

79
Views
El cliente Socket.IO 4.x no recibe eventos al conectarse

Aquí está el código:

 const app = express() const server = http.createServer(app) const io = new Server(server, { cors: { origin: "*", methods: ["PUT", "GET", "POST", "DELETE", "OPTIONS"], } }) io.on('connection', socket => socket.emit('message', 'well hello there')) server.listen(APP_PORT, APP_HOST, () => { console.log(`Listening on ${APP_HOST}:${APP_PORT}`) })

Nada especial en el lado del cliente:

 const socket = io(url) ... socket.connect()

Cuando me conecto, nada más que "sondas" (esas cosas 2probe 3probe) y dígitos aparecen en el depurador web.

Sin embargo, si agrego un retraso significativo en el lado del servidor como este

 io.on('connection', socket => setTimeout(() => socket.emit('message', 'well hello there'), 500))

todo "funciona": el cliente ahora puede recibir el mensaje (los tiempos de espera pequeños por debajo de ~ 350 ms no funcionan por cierto).

¿Por qué está pasando esto? ¿Algunas ideas?

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!