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

155
Views
El cliente JS socket.io no detecta un evento emitido

Estoy usando un servidor socketio basado en Python y un cliente socketio JS. El flujo de trabajo se ve más o menos así: client emits <<action1>> -> server receives <<action1>> -> server performs some calculations -> server emits <<action2>> -> client receives <<action2>> Debería funcionar en un bucle

El problema es que, por alguna razón, no se realiza el último paso, el cliente no parece detectar el evento action2 . Puedo ver que ha sido disparado desde los registros del servidor, afirman que: emitting event "action2" to all [/]

Servidor:

 @sio.on('action1') def handle_analysis(): ... some calculations ... sio.emit('action2')

Cliente:

 import { io } from "socket.io-client"; export const socket = io("http://localhost:5550", { timeout: 200000 }); async runCalculations() { console.log('progress1'); let stdoutChunks: string = ''; const getCalculations = () => { socket.emit('action1'); return new Promise((resolve, reject) => { socket.on('action2', (msg) => { stdoutChunks += msg; resolve(stdoutChunks); }) }); }; await getCalculations() console.log('progress2'); return {}; }

progress2 nunca se registra, porque js sigue esperando la función getCalculations . ¿Alguien puede señalar dónde podría estar el problema? Cada cálculo toma aproximadamente 50 segundos, me pregunto si esa podría ser la causa. Usé el mismo enfoque para diferentes eventos que toman mucho menos tiempo y funciona perfectamente, el servidor se comunica con el cliente sin problemas.

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!