Title: ECONNRESET while doing http 1.1 keep alive requests and server closes the connections · Issue #47130 · nodejs/node · GitHub
Open Graph Title: ECONNRESET while doing http 1.1 keep alive requests and server closes the connections · Issue #47130 · nodejs/node
X Title: ECONNRESET while doing http 1.1 keep alive requests and server closes the connections · Issue #47130 · nodejs/node
Description: Version v18.15.0 Platform Running this in a Kubernetes cluster inside nodejs:lts container. Details for K8s node "nodeInfo": { "architecture": "amd64", "bootID": "a5847523-d870-4bc0-9f1a-7a4ed9885ca3", "containerRuntimeVersion": "docker:...
Open Graph Description: Version v18.15.0 Platform Running this in a Kubernetes cluster inside nodejs:lts container. Details for K8s node "nodeInfo": { "architecture": "amd64", "bootID": "a5847523-d870-4bc0-9f1a-7a4ed9885c...
X Description: Version v18.15.0 Platform Running this in a Kubernetes cluster inside nodejs:lts container. Details for K8s node "nodeInfo": { "architecture": "amd64", "bootID&qu...
Opengraph URL: https://github.com/nodejs/node/issues/47130
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ECONNRESET while doing http 1.1 keep alive requests and server closes the connections","articleBody":"### Version\r\n\r\nv18.15.0\r\n\r\n### Platform\r\n\r\nRunning this in a Kubernetes cluster inside nodejs:lts container. Details for K8s node \"nodeInfo\": { \"architecture\": \"amd64\", \"bootID\": \"a5847523-d870-4bc0-9f1a-7a4ed9885ca3\", \"containerRuntimeVersion\": \"docker://20.10.12\", \"kernelVersion\": \"3.10.0-1160.53.1.el7.x86_64\", \"kubeProxyVersion\": \"v1.21.12\", \"kubeletVersion\": \"v1.21.12\", \"machineID\": \"\", \"operatingSystem\": \"linux\", \"osImage\": \"Red Hat Enterprise Linux\", \"systemUUID\": \"290B2642-439A-2099-6F2B-7ED84D7C284B\" },\r\n\r\n### Subsystem\r\n\r\nhttp or net\r\n\r\n### What steps will reproduce the bug?\r\n\r\nRun non stop http1.1 requests over a keepAlive connection pool using ``node-fetch`` or ``axios`` against any server that closes the connection from its side after 'N' seconds. In my case the server did a 20 second close. There might be multiple requests to the server over the connection but if 20 seconds have elapsed it closes the connection after the the last http response is sent.I have a default nodejs client configuration ( I haven't assigned it more threads or anything).\r\n\r\nWhen configuring the custom http agent on the client side, i supplied ``{keepAlive: true, maxSockets:50}``.\r\n\r\n\r\n### How often does it reproduce? Is there a required condition?\r\n\r\nWhen the there's a lot of requests being sent constantly things are fine, but if there is a slowdown(not many things do, hence lesser requests to go out) - the next request usually ends up getting an ECONNRESET. \r\n\r\nBased on my TCP dump I have, when there's a good load of requests over the connection pool when the server sends a \r\n[FIN, ACK], the client sends a [FIN,ACK] and the server sends an ACK back and the connection closes successfully \r\n\r\nBut when there is a \"lull\" later and there's not enough requests over the pool, the server sends a [FIN,ACK] for an unused connection in the pool, the nodejs client responds [ACK] and the next request in the queue goes on this socket causing the server to respond with a RESET. (Rightly so - coz the server wanted to close the connection).\r\n\r\nNow I believe the reason for the next request to go on the socket that just got the FIN has probably has to do with connection choosing strategy. I think the default is both these frameworks is lifo, and the ACK (without the FIN) that gets sent makes the connection go to the top of the pool for the next request. \r\n\r\n\r\n\r\n### What is the expected behavior? Why is that the expected behavior?\r\n\r\nA socket closed from the server side (FIN,ACK sent by server) must be removed from the connection pool instead of it being kept in there - Regardless of the fact that a FIN wasn't sent back. And no future requests should go on it.\r\n\r\n### What do you see instead?\r\n\r\nThe connection stays in the pool if the FIN wasn't sent back. The next request goes on the connection. Sever forcibly closes connection with a RESET\r\n\r\n### Additional information\r\n\r\nI tried a few other frameworks apart from node-fetch and axios (same issue, making me think it's a node core problem) - But I can't use them in my code so not mentioning them . \r\n\r\nWhen I reduced ``maxSockets`` from 50 to 20 the issue happened less frequently. Which is why i think it is related activity on those sockets. I switch to the ``keepaliveagent`` package that has a SocketTTL feature - it helps, but doesn't solve the problem . Resets still happen (same issue). Seems like this issue was [reported there](https://github.com/node-modules/agentkeepalive/issues/57) and they tried to handle it there (still a problem though). I'm assuming [this issue](https://github.com/MicrosoftDocs/azure-docs/issues/29600) has the same problem I'm facing - they were using ``keepaliveagent`` as well.","author":{"url":"https://github.com/DevasiaThomas","@type":"Person","name":"DevasiaThomas"},"datePublished":"2023-03-17T07:16:41Z","url":"https://github.com/nodejs/node/issues/47130"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:303dc152-96a2-857f-f7cd-2fb7f026c2cd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9ADC:6AD3D:AC22AB:DF4A79:6B0638BE |
| html-safe-nonce | a1973ad71de93acf4fc72be385538a611ff088e58a9f2350859ba2ecff3c8bd6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QURDOjZBRDNEOkFDMjJBQjpERjRBNzk6NkIwNjM4QkUiLCJ2aXNpdG9yX2lkIjoiMzkzMzU3MDA4MzU4MjI2MTQzOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7f799f852c613560c204122ff49f64caf1b93c0d8b80d5aed4247957fb2ce5e3 |
| hovercard-subject-tag | issue:1628823234 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/47130/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7b75c642ba71153cf7eab7dede576d3fe729ae460238d045e980b77253054b81/nodejs/node/issues/47130 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7b75c642ba71153cf7eab7dede576d3fe729ae460238d045e980b77253054b81/nodejs/node/issues/47130 |
| og:image:alt | Version v18.15.0 Platform Running this in a Kubernetes cluster inside nodejs:lts container. Details for K8s node "nodeInfo": { "architecture": "amd64", "bootID": "a5847523-d870-4bc0-9f1a-7a4ed9885c... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DevasiaThomas |
| hostname | github.com |
| expected-hostname | github.com |
| None | dcf72c457c022486d23c3cbb0dd21aba537a87611ca9ddabd1799cf2eaa9b297 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 0f38f5735226749ec5e08a8649dce4cb2613d9ad |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width