问题
I am attempting to create my first Google Home Action as with the same functinality of my Amazon Alexa Skill. The way this action works is, you execute an intent, and that calls a function in my code. When the function is called, it sends off a GET to an external API to pull some data.
Now when I run this locally using: firebase serve --only functions
and ngrok
. These will allow me to test the function on API.AI and it works fine.
But when I decide to deploy this to firebase using: firebase deploy --only functions
, it simply does not work and throws this error:
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 }
I cannot seem to find any reason why this would not work, as I can test it locally and get the data by hitting the same URL that is used in the request. In this example, I am using request-promise
to complete the request, but I have also used the libraries: got
, request
, and https
.
How can I overcome this problem?
回答1:
The only thing that I found for this could be that I am not using a paid Firebase plan
来源:https://stackoverflow.com/questions/44971441/deployed-firebase-function-cannot-execute-http-get-to-external-api