Firebase在所有http请求上都有ENOTFOUND功能 [英] Firebase functions ENOTFOUND on all http requests

查看:251
本文介绍了Firebase在所有http请求上都有ENOTFOUND功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置一个使用Express并发出HTTP请求的函数,但是无论是否提出请求,我总是收到一个ENOTFOUND错误。

I'm trying to set up a function that uses Express and makes HTTP requests, but I always get an ENOTFOUND error, no matter the request I make.

我已经尝试使用4个不同的库(https,请求,请求承诺,requestify)进行请求,但都提供相同的错误。

I already tried making the requests using 4 different libraries (https, request, request-promise, requestify), but all give the same error.

我按照这些示例设置系统: minimal-webhook + authorized-https-endpoint

I followed this examples to set up the system: minimal-webhook + authorized-https-endpoint.

我的基本测试功能,也会引发错误:

My basic test function, that also throws the error:

"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请求记录到 https://us-central1-project-abc.cloudfunctions.net/test/ 使用邮递员,例如:

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


推荐答案

getaddrinfo ENOTFOUND 错误意味着您的DNS解析器找不到DNS地址。也许您需要使用代理或不同的DNS解析器。确保您的Firebase功能完全可以进行出站Internet连接。

The ENOTFOUND error for getaddrinfo means that your DNS resolver cannot find the DNS address. Maybe you need to use a proxy or a different DNS resolver. Make sure that your Firebase function can make outbound internet connections at all.

这篇关于Firebase在所有http请求上都有ENOTFOUND功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆