【问题标题】:Deployed Firebase Function Cannot Execute HTTP GET to external API? [duplicate]部署的 Firebase 函数无法执行 HTTP GET 到外部 API? [复制]
【发布时间】:2017-12-11 18:59:17
【问题描述】:

我正在尝试创建我的第一个 Google Home Action,就像我的 Amazon Alexa Skill 一样功能。此操作的工作方式是,您执行一个意图,并在我的代码中调用一个函数。调用该函数时,它会向外部 API 发送 GET 以提取一些数据。

现在,当我使用 firebase serve --only functionsngrok 在本地运行它时。这些将允许我在 API.AI 上测试该功能,它工作正常。

但是当我决定使用 firebase deploy --only functions 将其部署到 firebase 时,它​​根本不起作用并抛出此错误:

error: { RequestError: Error: getaddrinfo EAI_AGAIN newsapi.org:443
    at new RequestError (/user_code/node_modules/request-promise/node_modules/request-promise-core/lib/errors.js:14:15)
    at Request.plumbing.callback (/user_code/node_modules/request-promise/node_modules/request-promise-core/lib/plumbing.js:87:29)
    at Request.RP$callback [as _callback] (/user_code/node_modules/request-promise/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at self.callback (/user_code/node_modules/request/request.js:188:22)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at Request.onRequestError (/user_code/node_modules/request/request.js:884:8)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at TLSSocket.socketErrorListener (_http_client.js:310:9)
    at emitOne (events.js:96:13)
    at TLSSocket.emit (events.js:188:7)
    at connectErrorNT (net.js:1020:8)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)
  name: 'RequestError',
  message: 'Error: getaddrinfo EAI_AGAIN newsapi.org:443',
  cause: 
   { Error: getaddrinfo EAI_AGAIN newsapi.org:443
       at Object.exports._errnoException (util.js:1026:11)
       at errnoException (dns.js:33:15)
       at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
     code: 'EAI_AGAIN',
     errno: 'EAI_AGAIN',
     syscall: 'getaddrinfo',
     hostname: 'newsapi.org',
     host: 'newsapi.org',
     port: 443 },
  error: 
   { Error: getaddrinfo EAI_AGAIN newsapi.org:443
       at Object.exports._errnoException (util.js:1026:11)
       at errnoException (dns.js:33:15)
       at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
     code: 'EAI_AGAIN',
     errno: 'EAI_AGAIN',
     syscall: 'getaddrinfo',
     hostname: 'newsapi.org',
     host: 'newsapi.org',
     port: 443 },
  options: 
   { uri: 'https://newsapi.org/v1/articles?source=hacker-news&sortBy=top&apiKey=8b87b4978b22493cadeb351cce01d52a',
     headers: { 'User-Agent': 'Request-Promise' },
     family: 4,
     json: true,
     callback: [Function: RP$callback],
     transform: undefined,
     simple: true,
     resolveWithFullResponse: false,
     transform2xxOnly: false },
  response: undefined }

我似乎找不到任何不可行的原因,因为我可以在本地对其进行测试并通过点击请求中使用的相同 URL 来获取数据。在此示例中,我使用 request-promise 来完成请求,但我也使用了以下库:gotrequesthttps

我该如何克服这个问题?

【问题讨论】:

标签: node.js firebase google-cloud-functions google-home


【解决方案1】:

我发现的唯一问题可能是我没有使用付费 Firebase 计划

【讨论】:

  • 这是否包括在 Google App Engine express URL 上调用 URL?!
  • 是的,升级到 Blaze(即付即用)为我解决了这个问题!
猜你喜欢
  • 1970-01-01
  • 2019-05-26
  • 2020-07-02
  • 2018-12-31
  • 2017-03-31
  • 2020-10-25
  • 2018-06-20
  • 1970-01-01
  • 2019-03-26
相关资源
最近更新 更多