-
Notifications
You must be signed in to change notification settings - Fork 7.3k
ECONNREFUSED causes node process to exit #136
Comments
Sorry, this misformats. Raw text: |
catch the 'error' event. your port should be an integer. |
Port as integer makes no difference. Catching the error event of the client worked. Thanks, that wasn't entirely obvious. Working code: |
can you check to see if you see this issue on the latest HEAD ? |
Sorry ry, not sure which issue we're talking about? As you pointed out correctly, catching the error event worked to prevent node.js from exiting, just that the error event handler is to be attached to the client, not the request. Therefore not a bug in my eyes, but maybe should be documented somehow. Thanks for your help. |
cool. closing. |
Hello,
if the connection is refused, HTTP client exits.
Example:
var sys = require('sys'), http = require('http');
var node = {
"host" : "127.0.0.1", // local host
"port" : "8300" // randon port that is not listening
};
try{
var client = http.createClient(node.port, node.host);
var request = client.request('GET', '/', {"host" : node.host});
request.addListener('response', function (response) {
if(response.statusCode == 200) {
sys.puts(node.host+':'+node.port+' active');
_active = node;
}
});
request.addListener('error', function (response) {
sys.puts('error');
});
request.end();
} catch(e) {
sys.puts('catch here');
}
$ node test-refused.js Error: ECONNREFUSED, Connection refused at IOWatcher.callback (net:757:22) at node.js:176:9
Should there not be an event that catches this, i.e. "refused"?
The text was updated successfully, but these errors were encountered: