Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

require('request').forever() #425

Closed
arisolt opened this Issue Feb 1, 2013 · 4 comments

Comments

Projects
None yet
3 participants

arisolt commented Feb 1, 2013

Hi,

In the code below, would the second request re-use the socket, or create a new connection?

var request = require('request').forever()
  , pool = { maxSockets: 1 };

request({ url: 'http://127.0.0.1:9012', pool: pool, timeout: 1}, function(error, response, body) {
    // not important
});

setTimeout(function () {
    request({ url: 'http://127.0.0.1:9012', pool : pool}, function(error, response, body) {
        // not important
    });
}, 2000);

arisolt commented Feb 1, 2013

Second question would be –

If the connection remains open "forever", how do I close it?

ehd commented Feb 5, 2013

would the second request re-use the socket, or create a new connection?

No, it would be closed because no requests were queued. See this comment.

how do I close it?

It closes itself if there are no pending requests.

I'm not 100% sure because this is a rabbit hole for me. Someone should confirm or deny this.

arisolt commented Feb 5, 2013

I am following the advice in this thread, btw:
https://groups.google.com/d/msg/nodejs/ZI6WnDgwwV0/sFm4QKK7ODEJ

Owner

mikeal commented Aug 28, 2014

Is this still an issue?

This is so old I'm closing, if it is actually still an issue just let me know and I'll re-open.

@mikeal mikeal closed this Aug 28, 2014

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