M
M
maddread2016-12-27 06:11:23
Node.js
maddread, 2016-12-27 06:11:23

Is it possible to make node work asynchronous in this case?

on a post request, the script accesses the piece of iron via snmp and returns its response.

app.post('/checkHw',function(req,res){
  var ip=req.body.ip;
  обращение по ip;
  ответ в response;
}

How to achieve asynchrony in this case, if the work is blocked while accessing the hardware?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
rustler2000, 2016-12-27
@maddread

If you pull net-snmp through a shell script, then child_process.exec (see https://nodejs.org/api/child_process.html#child_pr... asynchronous. I assume that this works through popen, although most likely it has its own wrapper, in order not to suffer with crookedly implemented popen.If
in general net-snmp directly from the same process, for example through the C API, then it's better not to do this :D
If snmp is a pure nodejs module, then it is 100% (ok - 99%) asynchronous. Don't like callback hell - then promises or generators.

V
Vitaly, 2016-12-27
@vitali1995

address by ip;

This command should be executed asynchronously - it's simple :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question