Cloud Functions puppeteer Error: net::ERR_NAME_RESOLUTION_FAILED at http://www.google.com

Ana Houa

On google Cloud Functions when I try to use puppeteer I get the following error for all sites that I try, an example for google.com:

Error: net::ERR_NAME_RESOLUTION_FAILED at http://www.google.com
    at navigate (/srv/node_modules/puppeteer/lib/FrameManager.js:101:37)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:229:7)
  -- ASYNC --
    at Frame.<anonymous> (/srv/node_modules/puppeteer/lib/helper.js:110:27)
    at Page.goto (/srv/node_modules/puppeteer/lib/Page.js:656:49)
    at Page.<anonymous> (/srv/node_modules/puppeteer/lib/helper.js:111:23)
    at /srv/index.js:35:20
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:229:7)

the Cloud Functions code:

    const functions = require("firebase-functions");
    const cors = require("cors")({origin: true});
    const Firestore = require("@google-cloud/firestore");
    const puppeteer = require("puppeteer");
    const cheerio = require("cheerio");

    exports.getSiteOne = functions
      .runWith({ memory: "2GB" })
      .https.onRequest((req, res) => {
        cors(req, res, async function() {
          try {
            const browser = await puppeteer.launch({
              headless: true,
              args: ["--no-sandbox", "--disable-setuid-sandbox"]
            });
            const page = await browser.newPage();

            await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3419.0 Safari/537.36');

            await page.goto("http://www.google.com", {
              waitUntil: "networkidle0"
            });

            var html = await page.content();

            res.status(200).json({
              message: "cron added",
              html
            });
          } 
          catch (err) {
            console.log(err);
            res.status(500).json({
              error: err
            });
          }
        });
      });

puppeteer version "^1.14.0"

NB: when I serve it locally it works fine

Thomas Dondorf

The error is saying that the DNS lookup fails. I'm assuming you are on the free "Spark Plan". That one is not allowing any outgoing traffic:

Outbound networking: Google services only

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

puppeteer.launch in Cloud Functions throwing error

Google cloud functions http authentication

Authentication in HTTP Google Cloud Functions

Is it safe to use Google cloud functions and puppeteer for user code sandbox?

Puppeteer PDF Creation on Firebase Functions (Google Cloud) times out

www.google.com returns HTTP 301

Puppeteer Crawler - Error: net::ERR_TUNNEL_CONNECTION_FAILED

Secure Google Cloud Functions http trigger with auth

Google Cloud Functions: monitor HTTP status codes

HTTP POST Google Cloud Functions NodeJS

Using .NET Function Framework with multiple Google Cloud HTTP Functions in one project; how to set entry point for debugging?

firebase cloud functions http error code 403

Firebase/Google cloud functions - is it possible to hook into cloud functions error event?

Can't use www.google.com NET::ERR_CERT_COMMON_NAME_INVALID SSL certificate is not valid

GET https://www.google-analytics.com/analytics.js net::ERR_CONNECTION_REFUSED

Distinguish HTTP and onCall Trigger of cloud functions by Google Cloud API

Random Connection Error in Google Cloud Functions (Python)

Cannot deploy google cloud functions (error: ELIFECYCLE)

Google structured data error: "All values provided for http://www.example.com/ must have the same domain."

undefined method `hostname' for "'http://www.google.com/":String (NoMethodError)

Error:External resource http://www.example.com/ is not registered

Website access denied using puppeteer on cloud functions

running puppeteer code in firebase cloud functions

How to get HTTP request body size in Google Cloud Functions?

Do Google Cloud Platform HTTP Functions Support Route Parameters?

How to send a HTTP request from Google Cloud Functions (nodeJS)

How to make an http response in python in google cloud functions

How to get execution ID for Google Cloud Functions triggered from HTTP?

Is there number of request limit for sending HTTP request from Google Cloud Functions?