简体   繁体   中英

Using multiple proxies via request.js

I am trying to send a list of proxy addresses to requestjs & want it to use first one that's is working. Is it at all possible via request.js

My code is

 var body = '<sample/>';
 request.post({
                url: www.google.com,
                proxy':'http://proxy1:8087;http://proxy2:8080',//need to use multiple proxies here.
                headers: { //We can define headers too
                    'Content-Type': 'text/xml'
                },
                body: body,
                timeout:20000
            }

I am thinking of looping through list of proxies and try to use them one by one. I am not sure if that would have been an overkill or is the only way possible.

requestjs cannot loop through proxies, the best possible option is to use an agent module alongwith it like https://www.npmjs.com/package/pac-proxy-agent

But even this module does not iterate through the list for now. The only feasible option is to loop through the list of proxies and use the first one reachable for now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM