V
V
Vladimir Krauz2016-08-14 23:35:30
JavaScript
Vladimir Krauz, 2016-08-14 23:35:30

NodeJS How can I keep an http connection for a certain time?

Good evening!
In general, I'm interested in the question of saving an http connection for a certain time.
Why do I need it?
I need to receive certain data from the post request, then send this data to the daemon (service), after the daemon responds and gives the processed data, and we will have to return the same data in response to the http request. The daemon can return data after nth time, in the form of 10sec - 5 minutes.
How can you keep the connection alive without stopping all other connections? Observing the asynchrony of programming.

app.post('upload/', function (req, res, next) {
   var data = ...; // получаю нужную информацию из post запроса
   // Pseudocode begin 
   daemon.write(data); // отправляю полученные данные в демон по TCP соединению
   var outFile = daemon.read(); // получаю обработанные данные из демона 
   // Pseudocode end
   res.end(outFile); // возвращаю данные в ответ
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly, 2016-08-14
@MelancholicTheDie

https://github.com/request/request-promise

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question