nathanaschbacher / nodiak

Nodiak is a Node.js client for the Riak Distributed Database
MIT License
43 stars 16 forks source link

keep-alive connections cause ECONNRESET errors #1

Closed nathanaschbacher closed 12 years ago

nathanaschbacher commented 12 years ago

There seems to be something wrong with the socket pooling in node.js which causes ECONNRESET errors to throw when the pooling mechanism is overwhelmed.

I don't think it's an issue where the connections are actually being reset by the host, because if I increase the http.globalAgent.maxSockets value to something large like 100 the problem is generally mitigated (until those 100 sockets are overwhelmed).

If it were a problem with Riak pre-maturely closing connections, then it would seem that increasing maxSockets would make things worse faster, not make them better longer.

nathanaschbacher commented 12 years ago

The current "fix" for this is to set the Agent to false on requests, which causes the connection to be closed on each request.

Ideally the socket pooling functionality would be more stable, but the better long-term fix will be to implement an auto-retry on request error.

nathanaschbacher commented 12 years ago

This turns out to be an issue isolated to DELETEs, and is due to an idiosyncrasy in both node.js and MochiWeb.

Basically any DELETE that's chunked and/or includes a body will cause MochiWeb to close the connection. This happens to be node's default behavior.

nathanaschbacher commented 12 years ago

Closed by: https://github.com/Coradine/nodiak/commit/218b24dc38be882b12635e18c28357f4018d0fe4