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
How to set maxSockets for all requets to be #1150
Comments
we need to treat the pool option the same way we do headers, creating a full copy of the underlying option. |
is there a workaround for this problem? |
It seems to be working on my end: var sharedPool = { maxSockets: 5 };
var req = request.defaults({pool: sharedPool});
var r = req.get('http://google.com', function(err, response) { console.log(r.pool) });
// Outputs a pool containing agents with maxSocket = 5
sharedPool.foo = 'bar';
var r = req.get('http://google.com', function(err, response) { console.log(r.pool) });
// Outputs a pool containing agents with maxSocket = 5 and with property foo='bar' The first output tests that maxSockets is properly set. The second tests that all requests are using the same, shared pool so that maxSockets is actually having an effect. (These were all done in the repl with enough time for the first request to come back before firing the second one). @ekelvin request.defaults() doesn't change the actual request module, it returns a new, wrapped module for you to use. Try this:
|
As @FredKSchott said, do |
This has come up several times recently, for example request#1150 and request#1249.
This has come up several times recently, for example request#1150 and request#1249.
I tried the request.defaults to set hte maxSocket: 3 but the problem still persists, thousands of requests are sent to the server in parallel :S :(.
here is my try, notice download is with callback
The text was updated successfully, but these errors were encountered: