http-browserify icon indicating copy to clipboard operation
http-browserify copied to clipboard

How to catch ECONNREFUSED?

Open goloroden opened this issue 11 years ago • 3 comments

In Node.js, when using the request function of the http module, you can subscribe to the error events of the returned object, such as:

var http = require('http');

var req = http.request('aaa.bbb.ccc.ddd', function (res) {
  console.log(res.statusCode);
});

req.on('error', function (err) {
  console.log('###');
});

req.end();

When I run this with a non-existent IP on Node.js, everything is fine, and the result is ### printed to the console.

When I run this using http-browserify in Chrome, I get an uncaught exception. Am I doing something wrong?

goloroden avatar Jun 23 '14 11:06 goloroden

I'm having the same issue. Any resolution to this?

JamesMessinger avatar Dec 03 '14 19:12 JamesMessinger

Unfortunately, I don't have one :-(

goloroden avatar Dec 04 '14 19:12 goloroden

I believe you will have to listen to the window for these uncaught network errors and decide what to do with them.

langri-sha avatar Mar 16 '16 22:03 langri-sha