-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http.Agent: idle sockets throw unhandled ECONNRESET #3595
Comments
Reproducing your code here for the sake of posterity: var http = require("http");
var domain = require("domain");
function log() {
var args = [].slice.call(arguments);
args.unshift(process.uptime()+"s:");
console.log.apply(console, args);
}
var agent = new http.Agent({
keepAlive: true,
keepAliveMsecs: 10000
});
var req = http.request({
hostname: "www.asp.net",
port: 80,
path: "/",
method: "GET",
agent: agent
}, function(res) {
res.on("data", function() {
});
res.on("end", function() {
log("Complete");
});
});
req.on("socket", function(sock) {
sock.on("close", function() {
log("socket closed");
});
});
req.on("error", function(err) {
log("an error ocurred", err);
});
process.on('uncaughtException', function(err) {
log("uncaughtException");
console.error(err.stack);
process.exit();
});
req.end();
setTimeout(function() {
log("done");
}, 300000); I'm not sure what you think I don't see a bug here. I'll close the issue. |
I'm really confused. https://nodejs.org/api/http.html states the opposite:
|
Maybe I should have said: If you think the documentation is unclear, can you file an issue for that and suggest improvements or send a pull request? |
I still can't get it. |
Because ECONNRESET is an exceptional error, it means the remote end forcibly closed the connection. If the agent swallowed the error you couldn't distinguish an empty reply from unclean termination, for example. |
An empty reply to what? The discussed exception happens when the socket is waiting in the pool and isn't used for a request. |
With all due respect, that's not very clear from your original message. I'll reopen the issue, pull requests welcome. |
For whoever is picking this up, it's probably worth mentioning that the naive solution of attaching an error listener in the agent's |
Hello, I am facing the same issue in signalr which uses long polling and my program stops in 2 mins. This was working fine before node.js upgrade from 0.12.6 to 4.1.2 |
I think it will be nice if the Http Agent had a |
No, this issue is only about free (idle) sockets. |
This change adds a new event handler to the `error` event of the socket after it has been used by the http_client. The purpose of this change is to catch errors on *keep alived* connections from idle sockets that otherwise will cause an uncaugh error event on the application. Closes nodejs#3595
@mikemorris looks like this fix shipped with 4.4.0 (and 5.4.0). |
Hi, we are also getting an ECONNRESET error. I'm not sure if this is the same bug?
Version: 4.2.2 |
@aymeba No. This issue is only about idle sockets in the pool. It's not about sockets assigned to requests (your case).. |
@thorn0 thanks. Is there a known issue about requests? |
@aymeba Why do you think it's a bug in Node? |
@thorn0 I'm not sure if it is a bug, therefore I am asking whether there is a known issue about such cases? Because we setup everything in our info such ulimit etc. But it happens every 15 seconds periodic on different API calls |
@aymeba I don't know about such known issues. |
Thank you @thealphanerd and whole Node team for release this fix in 4.x branch. |
This change adds a new event handler to the `error` event of the socket after it has been used by the http_client. The purpose of this change is to catch errors on *keep alived* connections from idle sockets that otherwise will cause an uncaugh error event on the application. Fix: nodejs#3595 PR-URL: nodejs#4482 Reviewed-By: Fedor Indutny <[email protected]>
Is this going to be ported into the |
@nodesocket v0.12 is in maintenance mode now, meaning that it gets security fixes but not much more. Though if you or someone else is willing to work on the backport, we'll certainly review it. |
I've got also ECONNRESET error. But it is really weird. It was calling google place api using axios, also I tried node-fetch as well. |
Please see this code: https://gist.github.com/thorn0/0812cdb7eb12b2348337
That's what it outputs for me (Node 4.2.1 and 5.0.0, Windows 7 x64):
It's reproduced with most servers that run Microsoft IIS.
The text was updated successfully, but these errors were encountered: