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

157
Views
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
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!