Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

162
Vistas
JS socket.io client doesn't catch an emitted event

I'm using a Python based socketio server and JS socketio client. The workflow looks roughly like this: client emits <<action1>> -> server receives <<action1>> -> server performs some calculations -> server emits <<action2>> -> client receives <<action2>> It should work in a loop.

The problem is that for some reason the last step isn't performed, client doesn't seem to catch action2 event. I can see that it has been fired from the server logs, they state that: emitting event "action2" to all [/]

Server:

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

Client:

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 is never logged, because js keeps on awaiting the getCalculations function. Can anyone point where the issue might be? Each calculation takes roughly 50 seconds, I wonder if that might be the cause. I used same approach for different events that take much less time and it works perfectly, server communicates with the client without problems.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda