-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Why the http client does not support the keep alive feature? #33853
Comments
I think this is traditionally solved as is described on the following page. https://www.jstips.co/en/javascript/working-with-websocket-timeout/ At least that's how I've solved it for myself, anyone else please feel free to add 2¢. |
Thanks, you found the correct answer to the question. |
I think you have to consume the response data received on client side. Try adding |
Closing as answered. |
Why the http client does not support the keep alive feature?
TCP socket should be reused in multiple requests.
But the result is that the request and response are sent only once per connection.
nodejs v14.2.0
Linux localhost 4.9.148 #1 SMP PREEMPT Tue Mar 10 02:27:59 CST 2020 aarch64 Android
What steps will reproduce the bug?
client.js
server.js
How often does it reproduce? Is there a required condition?
100%
What is the expected behavior?
TCP socket should be reused in multiple requests.
What do you see instead?
$ node /storage/emulated/0/test/client.js 127.0.0.1 44284 { date: 'Fri, 12 Jun 2020 04:22:52 GMT', connection: 'keep-alive', 'transfer-encoding': 'chunked' } 127.0.0.1 44286 { date: 'Fri, 12 Jun 2020 04:22:52 GMT', connection: 'keep-alive', 'transfer-encoding': 'chunked' } 127.0.0.1 44288 { date: 'Fri, 12 Jun 2020 04:22:52 GMT', connection: 'keep-alive', 'transfer-encoding': 'chunked' } 127.0.0.1 44290 { date: 'Fri, 12 Jun 2020 04:22:52 GMT', connection: 'keep-alive', 'transfer-encoding': 'chunked' } 127.0.0.1 44294 { date: 'Fri, 12 Jun 2020 04:22:52 GMT', connection: 'keep-alive', 'transfer-encoding': 'chunked' } 127.0.0.1 44296 { date: 'Fri, 12 Jun 2020 04:22:53 GMT', connection: 'keep-alive', 'transfer-encoding': 'chunked' } 127.0.0.1 44300 { date: 'Fri, 12 Jun 2020 04:22:53 GMT', connection: 'keep-alive', 'transfer-encoding': 'chunked' } 127.0.0.1 44302 { date: 'Fri, 12 Jun 2020 04:22:53 GMT', connection: 'keep-alive', 'transfer-encoding': 'chunked' } 127.0.0.1 44304 { date: 'Fri, 12 Jun 2020 04:22:53 GMT', connection: 'keep-alive', 'transfer-encoding': 'chunked' } 127.0.0.1 44308 { date: 'Fri, 12 Jun 2020 04:22:53 GMT', connection: 'keep-alive', 'transfer-encoding': 'chunked' } 127.0.0.1 44310 { date: 'Fri, 12 Jun 2020 04:22:53 GMT', connection: 'keep-alive', 'transfer-encoding': 'chunked' } 127.0.0.1 44312 { date: 'Fri, 12 Jun 2020 04:22:54 GMT', connection: 'keep-alive', 'transfer-encoding': 'chunked' } 127.0.0.1 44314 { date: 'Fri, 12 Jun 2020 04:22:54 GMT', connection: 'keep-alive', 'transfer-encoding': 'chunked' } 127.0.0.1 44318 { date: 'Fri, 12 Jun 2020 04:22:54 GMT', connection: 'keep-alive', 'transfer-encoding': 'chunked' } 127.0.0.1 44320 { date: 'Fri, 12 Jun 2020 04:22:54 GMT', connection: 'keep-alive', 'transfer-encoding': 'chunked' } 127.0.0.1 44322 { date: 'Fri, 12 Jun 2020 04:22:54 GMT', connection: 'keep-alive', 'transfer-encoding': 'chunked' } 127.0.0.1 44324 { date: 'Fri, 12 Jun 2020 04:22:54 GMT', connection: 'keep-alive', 'transfer-encoding': 'chunked' } 127.0.0.1 44328 { date: 'Fri, 12 Jun 2020 04:22:54 GMT', connection: 'keep-alive', 'transfer-encoding': 'chunked' } 127.0.0.1 44330 { date: 'Fri, 12 Jun 2020 04:22:55 GMT', connection: 'keep-alive', 'transfer-encoding': 'chunked' } $
Additional information
The text was updated successfully, but these errors were encountered: