TooTallNate / proxy-agents

Node.js HTTP Proxy Agents Monorepo
https://proxy-agents.n8.io
919 stars 239 forks source link

maxSockets #105

Closed sm2017 closed 4 years ago

sm2017 commented 4 years ago

How can I set maxSockets?

Rasfuranku commented 4 years ago

Could the keepAlive parameter be included on this too?

Rasfuranku commented 4 years ago

I just find a work around for this. As the Agent is being created with the http.Agent you can access to its properties and set them.

const httpsAgentProxyAgent = new HttpsProxyAgent("http://0.0.0.0:8080");
httpsAgentProxyAgent.maxSockets = 40;

I still think it would be nice to have it as a parameter when creating the proxyAgent instance.

sm2017 commented 4 years ago

@Rasfuranku

As the Agent is being created with the http.Agent

How you find that it created with the http.Agent, Can you show me the source?

Rasfuranku commented 4 years ago

It is using the agent-base library which is an http.Agent generator. agent-base: https://github.com/TooTallNate/node-agent-base#readme Magic happens here: https://github.com/TooTallNate/node-agent-base/blob/bc0f58c1f02f545acd1a6bd887ed5b06b50874a9/src/index.ts#L91