apify / proxy-chain

Node.js implementation of a proxy server (think Squid) with support for SSL, authentication and upstream proxy chaining.

Home Page:https://www.npmjs.com/package/proxy-chain

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can I change the proxy if the current proxy is not responding?

tradua opened this issue · comments

I have a code:

const server = new ProxyChain.Server({
    port: 8011,
    verbose: true,
    timeout: 5000,
    proxyTimeout: 5000,
    prepareRequestFunction: ({ request, username, password, hostname, port, isHttp, connectionId }) => {
        return {
            upstreamProxyUrl: getRandomProxy(),
        };
    }
});

Sometimes I get an error from my proxy and want to replace it with another one. How can i do this?

The upstream proxy cannot be replaced on-the-fly for existing connections. If the upstream proxy fails, just close the connection, and next time when prepareRequestFunction() is called for the next request, just pick another proxy.

Closing this since this is not really a bug or issue.