asterisk / node-ari-client

Node.js client for ARI. This library is best effort with limited support.
Other
249 stars 98 forks source link

Trying to connect to an unreachable host doesn't always throw an error #143

Open fbernhard opened 4 years ago

fbernhard commented 4 years ago

This code should also check for "EHOSTUNREACH":

https://github.com/asterisk/node-ari-client/blob/0933f88a9ebb8244d0505cc4553da6ef0dd2777d/lib/client.js#L113

if request throws an "EHOSTUNREACH" the system continues with the connection attempt which leads the library to "hang".

https://nodejs.org/api/os.html#os_signal_constants

Alternatively, maybe check for statusCode 200?

request(ariUrl, function (err, response) {
      if (err || !response || response.statusCode !== 200) {

Thank you!