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

Windows : permission denied

therepo90 opened this issue · comments

const credentials = require(".././credentials");
const proxyChain = require("proxy-chain");

async function createSimpleProxy() {
    const proxyHttpPort = 15000;
    const proxyIp = `myip`;
    const oldProxyUrl = `http://${credentials.username}:${
        credentials.pw
        }@${proxyIp}:${proxyHttpPort}`;

    const newProxyUrl = await proxyChain.anonymizeProxy(oldProxyUrl);
    console.log(newProxyUrl);
    return newProxyUrl;
}

exports.createSimpleProxy = createSimpleProxy;

its being created properly getting http://127.0.0.1:26563
but after some time im getting

Unhandled rejection Error: listen EACCES: permission denied 0.0.0.0:49785
    at Server.setupListenHandle [as _listen2] (net.js:1260:19)
    at listenInCluster (net.js:1325:12)
    at Server.listen (net.js:1412:7)

no process is running at this port and im using admin rights

That's really strange, are you running many createSimpleProxy() calls in parallel? I'm guessing maybe two calls tried to use the same port number and had a collision. The server is using the findFreePort() function to find a free port, which is quite straightfoward:

https://github.com/apifytech/proxy-chain/blob/master/src/tools.js#L198

No, the above code is the only code I run

test.js:

const {createSimpleProxy} = require('./proxy.js');

createSimpleProxy();

The only thing I can think of is some bug in the https://www.npmjs.com/package/portastic package. We can try to replace it with e.g. https://www.npmjs.com/package/portfinder and see if that helps. However, I'm not sure when we'll find time to do this.

As a quick workaround, I'd recommend looking at the code of anonymizeProxy function, making your own local version, and replace findFreePort() call with a random or fixed port number that you know it's free

Okay lets close it. I've managed to use the example with
Run a HTTP/HTTPS proxy server with credentials and upstream proxy
Thanks for this tool anyway

Great, I'm glad to hear you were able to make it work. Closing this now

I hope portastic will fix this one day, it is pretty annoying with Puppeteer, spamming the log.

For anyone else getting this issue, you need to add an outbound rule for ports 20000-60000 in windows defender.