node-ari-client icon indicating copy to clipboard operation
node-ari-client copied to clipboard

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

Open fbernhard opened this issue 6 years ago • 0 comments

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!

fbernhard avatar Jun 12 '20 13:06 fbernhard