socks5-https-client
socks5-https-client copied to clipboard
Concurrent requests
When doing concurrent requests the first proxy used can never be changed.
var myip = "https://api.ipify.org?format=json";
var res = await request({
method: 'GET',
uri: myip,
agentClass: Agent,
agentOptions: {
socksHost: proxy.split(":")[0],
socksPort: proxy.split(":")[1]
},
rejectUnauthorized: false
});
This is giving me the same ip for every request while i change the proxy on every request.
179.209.175.59:28061 {"ip":"179.209.175.59"} 189.122.40.220:58577 {"ip":"179.209.175.59"} 189.6.142.94:16943 {"ip":"179.209.175.59"} 187.39.53.6:65000 {"ip":"179.209.175.59"} 177.142.117.96:46489
@wahid I had the same issue, maybe others will come to this page looking for a solution. In my case the issue was not related to this package, I had to add maxSockets option on request module:
var myip = 'https://api.ipify.org?format=json';
var res = await request({
method: 'GET',
uri: myip,
agentClass: Agent,
agentOptions: {
socksHost: proxy.split(':')[0],
socksPort: proxy.split(':')[1]
},
pool: {maxSockets: Infinity}, // <=======
rejectUnauthorized: false
});
pool- an object describing which agents to use for the request. If this option is omitted the request will use the global agent (as long as your options allow for it). Otherwise, request will search the pool for your custom agent. If no custom agent is found, a new agent will be created and added to the pool. Note:poolis used only when theagentoption is not specified.- A
maxSocketsproperty can also be provided on thepoolobject to set the max number of sockets for all agents created (ex:pool: {maxSockets: Infinity}). - Note that if you are sending multiple requests in a loop and creating multiple new
poolobjects,maxSocketswill not work as intended. To work around this, either userequest.defaultswith your pool options or create the pool object with the maxSockets property outside of the loop.
- A
I have the same problem, the second request will use the proxy set by the first request.