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

95
Vistas
Handle long-running request from Swift Client in Node.js

So I'm currently using socket.io for a loading screen and it just isn't working so I'm going to try a different solution. I need the following to happen: user opens up my app--this triggers a function on the server side (CPU intensive scraping function that takes about 8 seconds). As soon as function is done, I need to notify the client that the function is done and the client fetches the results (after this result is fetched the app loading screen closes and the user enters the app).

My current implementation is using socket.io emissions and processing the scraping function via Redis queue on a background thread.

Is there a different approach to doing this instead of a socket connection and sending emissions from client -> server and vice versa?

I don't think I can just to a classic GET request, because isn't it bad practice to leave a long running (8 second) request open for so long while waiting for response? Also, I looked into Server-Sent Events but I'm not sure I would be able to use it in this case.

Any insight is much appreciated!

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

8 seconds is longer than normal for a response from a "healthy" server, but still should be fine. I'd just use a GET from the mobile client, and write it to not block the UI while it is waiting.

Write your UI so that it informs the user that it is waiting for a response, and maybe even give the user an idea of how long the response is likely to take.

about 4 years ago · Juan Pablo Isaza Denunciar

0

A few points to keep in mind.

  1. nodejs can usually do a lot of concurrent web-scraping: most web-scraping elapsed time is spent waiting for the scraped servers to respond. nodejs is asynchronous. So worker threads may not help much. They definitely will make your server app more complex. A good choice for scaling this out might be clustering your nodejs app.
  2. There's no harm in writing your server to stall the response to a GET request for a few seconds, except harm to the user experience. If your user has something reasonable to look at for those few seconds, you can probably get away with this.
  3. If your user is looking at a web page during that stall, you can use xhr or fetch from Javascript code in the page to retrieve that data while you entertain them with a spinner or some such user interface stuff.
about 4 years ago · Juan Pablo Isaza Denunciar
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