Skip to content

Difference between http.request({keepAlive}) and http.request({agent: {keepAlive}}) #1300

Closed

Description

@vvo

Hi,

I have been playing with keepAlive in io.js and node 0.12. Something strange is that the documentation states that one could use:

http.request({keepAlive: true})

But this line did not trigger keepAlive on my requests. I could not find a code path using it in the nodejs codebase.

Is this a mistake or am I missing something? Maybe agent keepAlive and request keepAlive are not the same thing, then maybe we could clarify things.

Using:

http.request({agent: http.Agent({keepAlive: true})})

works, as shown in the tests https://github.com/joyent/node/blob/857975d5e7e0d7bf38577db0478d9e5ede79922e/test/simple/test-http-agent-keepalive.js
https://github.com/iojs/io.js/blob/v1.x/test/parallel/test-http-agent-keepalive.js

Activity

  1. added
    http
    on Mar 31, 2015
  2. Fishrock123 commented on Apr 9, 2015

    @Fishrock123
    Contributor

    keepAlive and keepAliveMsecs are wrongly indented in the docs. They should be indented one more level, since they are for http.Agent.

  3. self-assigned this
    on Apr 9, 2015
  4. Fishrock123 commented on Apr 9, 2015

    @Fishrock123
    Contributor

    Fixed in 69bc138, thanks for reporting! :)

  5. vvo commented on Apr 10, 2015

    @vvo
    Author

    awwww now it makes sense.. the nodejs docs as the same issue.

  6. vvo commented on Apr 10, 2015

    @vvo
    Author

    @Fishrock123 You sure this is the right fix?

    2015-04-10-094203_1142x357_scrot

    Reading this is confusing, it explains that agent: can take value keepAliveMsecs which is not true.

    I think we should just remove keepAlive and keepAliveMsecs from here and link to the Agent constructor where they are explained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

http

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions