Server not closing
therepo90 opened this issue · comments
using closeAnonymizedProxy without callback and using 'await' hangs and never closes the server.
version : latest
repro: example with anonymized proxy util function + add closeAnonymizedProxy at the end(before or after browser.close)
System : windows
Have you tried to set the closeConnections
parameter to true
? If it's false
, the function waits until all connections are closed, which can take an infinitely long time.
Tried to do it but now for some reason I keep getting:
Unhandled rejection Error: listen EACCES: permission denied 0.0.0.0:49685
even though nothing is running on this port and im using admin rights
Ill make another issue for that
No, I can't test this issue until the other is resolved :P
I came here to report the same issue. Here is the anonymizeProxy
code snippet from the README...
const proxyChain = require('proxy-chain');
(async() => {
const oldProxyUrl = '----------------:------------------@-----------:4444';
const newProxyUrl = await proxyChain.anonymizeProxy(oldProxyUrl);
// Prints something like "http://127.0.0.1:45678"
console.log(newProxyUrl);
const browser = await puppeteer.launch({
args: [`--proxy-server=${newProxyUrl}`],
});
// Do your magic here...
const page = await browser.newPage();
await page.goto('https://www.example.com');
await page.screenshot({ path: 'example.png' });
await browser.close();
await proxyChain.closeAnonymizedProxy(proxyUrl, true)
})();
I added the closeAnonymizedProxy
call to show that even with that, the node process does not exit. I have to manually call process.exit()
to get it to end.
I recommend using the second example for now until its resolved(it was sufficient for my needs) and server.close(or just process end) :
Run a HTTP/HTTPS proxy server with credentials and upstream proxy
what is the second example, I have errors all ports are used after some time because the anonymized proxy does not close
I realized the following statement in your code:
await proxyChain.closeAnonymizedProxy(proxyUrl, true)
contains proxyUrl
instead of newProxyUrl
. Please, can you fix it and try again, ideally with the newest release?