when remote site off-line getting error in consuming client (node.js v0.12.0 http module):
uncaught exception: connect econnrefused error: connect econnrefused @ exports._errnoexception (util.js:746:11) @ tcpconnectwrap.afterconnect [as oncomplete] (net.js:983:19) the code i'm using looks this:
var req = http.request(options, function (res) { res.on('socket', function (socket) { socket.setkeepalive(true, 0); socket.setnodelay(true); }); res.on('end', function () { log.debug('success'); }).on('error', function () { log.error('response parsing failed'); }); }).on('error', function () { log.error('http request failed'); }); req.write(packet); req.end(); the "error" event never fired when econnrefused occurs, i've tried using "clienterror" event not fired either.
how can capture error?
extracted from: https://stackoverflow.com/a/4328705/4478897
note: post bit old
the next example http.createclient think same
unfortunately, @ moment there's no way catch these exceptions directly, since stuff happens asynchronously in background.
all can catch uncaughtexception's on own:
process.on('uncaughtexception', function (err) { console.log(err); }); maybe helps you!
more this: https://stackoverflow.com/a/19793797/4478897
update:
did tried change log.error() console.error() ???
Comments
Post a Comment