对所有http请求使用Firebase函数ENOTFOUND

我试图设置一个函数,使用Express和发出HTTP请求,但我总是得到一个ENOTFOUND错误,无论我的要求。

我已经尝试使用4个不同的库(https,request,request-promise,requestify)提出请求,但是都给出了相同的错误。

我遵循这个例子来设置系统: minimal-webhook + authorized-https-endpoint 。


我的基本testingfunction,那也抛出了错误:

"use strict"; const functions = require("firebase-functions"); const admin = require("firebase-admin"); admin.initializeApp(functions.config().firebase); const express = require("express"); const app = express(); const https = require("https"); app.get("*", (req, res) => { var testReq = https.request({ host: "www.google.com", path: "/recaptcha/api/siteverify" }, (res) => { console.log("Finished with response " + res); }); testReq.on("error", (e) => { console.log("Crashed with error " + e); }); testReq.end(); }); exports.test = functions.https.onRequest(app); 

GET请求logging到https://us-central1-project-abc.cloudfunctions.net/test/使用邮递员,例如:

 Crashed with error Error: getaddrinfo ENOTFOUND www.google.com www.google.com:443 

getaddrinfoENOTFOUND错误意味着您的DNSparsing程序找不到DNS地址。 也许你需要使用代理或不同的DNSparsing器。 确保您的Firebasefunction可以完成出站互联网连接。

其实你只需要付费计划,以便能够提出外部要求。

Blaze计划(随时付费)对你来说可能是有好处的(我目前正在使用那个零费用计划)。

https://firebase.google.com/pricing/