Closed vvo closed 9 years ago
you use should agentkeepalive@0.2.x on node 0.10.x.
sorry. I am already using agentkeepalive 0.2
@fengmk2 any idea? Is this really a bug?
Hi, nice you have released agentkeepalive@2. This issue is still true, I tried it with latest agentkeepalive without success, process still hangs.
You can take the example code and it still hangs.
@fengmk2 I narrowed the test case and updated the issue description and title to be more precise.
It's not a "req.setTimeout" issue, only a keepAliveTimeout one.
Any hint?
you should listen res end event to sum the time.
Http for Google search is response 302, and it not a keepAlive connection. HTTPS for Google search is response 200, and it was keepAlive and socket will be hold.
Ok @fengmk2 I updated the examples to use www.example.com, added the end event, double checked that we were dealing with the same amount of xfered content. Same behavior: https agent only exits after keepAliveTimeout
Seems like this is the default behavior using standard http.Agent in Node too. Makes sense: your process will not exits if there's remaining keepalived sockets. I guess it could be smarter than that like understanding that the only alive timers are keepalived connections and that all of them are terminated (response received) and thus destroy the agent.
But for now, you can just call agent.destroy().
Thanks.
After further testing using the new agentkeepalive@2 on node 0.10:
HttpAgent
, nodejs will exit as soon as the last request was doneHttpsAgent
, nodejs will exit only after last request was done + keepAliveTimeoutHttp
agent:It takes 0.3 s to complete
Https
agent:It take 10.5s to complete
So the nodejs process only exits after the keepAlive timeout when using https agent.