On 27 August 2014 21:58, // ravi <[email protected]> wrote: > On Aug 27, 2014, at 4:40 PM, James Coglan <[email protected]> wrote: > > I'm trying to figure out how HTTP keep-alive works. According to the docs, > all requests by default use the global http.Agent (or https.Agent), which > pools connections per origin. Consider the following code; it starts a TCP > server that provides a basic response to HTTP requests and does not close > the socket. > > I do not know how well your TCP server code would work in certain > scenarios (e.g: when there is more than one chunk of request data, which, > if I am reading your code right, will cause a situation where a response is > sent by you before the end of the request), >
I know, it was just a quick hack to see what the HTTP client was doing at the TCP level. > but w.r.t http.Agent and keep-alives, you might find Issue 4769 an > interesting read (and my own comments, perhaps: > https://github.com/joyent/node/issues/4769#issuecomment-53116476). In > your case you are sending your third request when the response to the first > ends, which means (most likely) that after you fired the first and second > request, there was no request pending, which IIUC causes http.Agent to > close open keep-alive sockets. > That's what I suspected, but if it can't reuse a connection for concurrent requests, and won't reuse them for immediately sequential requests (which is the scenario I have in production), then when *does* it reuse connections? -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/CALm1c-GAXxU0BDy%2BEE%3DVLdDRTrWJfp4n-irsC0FBUjpqzpHwWg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
