Reputation: 9885
Background
I am running Puppeteer in an application locally that works fine. When I move it to a production debian server, it times out at the
page.goto(url)
function.
Example
I have tried a bunch of different suggestions online. In the example below you will see a few options I have tried that were suggested on line. I have tried these all alone and in different combinations with each other. Yes I am that desperate at this point.
const browser = await puppeteer.launch({
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--ignore-certificate-errors',
'--ignore-certificate-errors-spki-list',
'--user-data-dir']});
const page = await browser.newPage();
await page.goto(
`https://example.com/${template}?data=${JSON.stringify(req.body)}`, {waitUntil: 'networkidle0'}
);
page.goto(url) works locally, but fails when running on server.
Question
Why is page.goto()
failing on the server and is there any work around?
Upvotes: 0
Views: 153
Reputation: 1620
page.setDefaultNavigationTimeout
is your option
const browser = await puppeteer.launch({
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--ignore-certificate-errors',
'--ignore-certificate-errors-spki-list',
'--user-data-dir']});
const page = await browser.newPage();
page.setDefaultNavigationTimeout(3600); // 1 hour
await page.goto(
`https://example.com/${template}?data=${JSON.stringify(req.body)}`, {waitUntil: 'networkidle2'}
);
Upvotes: 1