This question already has answers here:
Cloud Functions for Firebase - getaddrinfo ENOTFOUND
(5 answers)
Closed 5 years ago.
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?
The only thing that I found for this could be that I am not using a paid Firebase plan
Related
Our servers are hosted on AWS EC2 Instance and we started receiving the following error today after the AWS Support changed somethings with DNS
Error: getaddrinfo EAI_AGAIN api.stripe.com:443
{ Error: An error occurred with our connection to Stripe.
at /var/www/html/Goeat/admin_and_store_panel/node_modules/stripe/lib/StripeResource.js:219:9
at ClientRequest.req.on (/var/www/html/Goeat/admin_and_store_panel/node_modules/stripe/lib/StripeResource.js:474:67)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at TLSSocket.socketErrorListener (_http_client.js:401:9)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:73:8)
at _combinedTickCallback (internal/process/next_tick.js:139:11)
at process._tickDomainCallback (internal/process/next_tick.js:219:9)
type: 'StripeConnectionError',
raw:
{ message: 'An error occurred with our connection to Stripe.',
detail:
{ Error: getaddrinfo EAI_AGAIN api.stripe.com:443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26)
errno: 'EAI_AGAIN',
code: 'EAI_AGAIN',
syscall: 'getaddrinfo',
hostname: 'api.stripe.com',
host: 'api.stripe.com',
port: '443' } },
rawType: undefined,
code: undefined,
doc_url: undefined,
param: undefined,
detail:
{ Error: getaddrinfo EAI_AGAIN api.stripe.com:443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26)
errno: 'EAI_AGAIN',
code: 'EAI_AGAIN',
syscall: 'getaddrinfo',
hostname: 'api.stripe.com',
host: 'api.stripe.com',
port: '443' },
headers: undefined,
requestId: undefined,
statusCode: undefined,
charge: undefined,
decline_code: undefined,
payment_intent: undefined,
payment_method: undefined,
setup_intent: undefined,
source: undefined }
Could you please help us with the issue ?
I'm trying to use Keyv, following this tutorial: https://discordjs.guide/keyv/#command-handler and I'm using the command handler code as well.
In my index.js, I run something like this: (with the appropriate imports for Keyv of course)
const Keyv = require('keyv');
const mykeyv = new Keyv('redis://user:pass#localhost:6379');
client.on('message', message =>{
...//skipping some command handler stuff
command.execute(message, args, mykeyv)
})
And then when I run this, I initially get the correct and expected client.on('ready') messages, but then a few seconds after the following error pops up:
events.js:292
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED 127.0.0.1:6379
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
Emitted 'error' event on Keyv instance at:
at KeyvRedis.<anonymous> (C:\Users\Meroper80\Documents\GitHub\DndBot\Node-Js-Discord-Bot\node_modules\keyv\src\index.js:43:44)
at KeyvRedis.emit (events.js:315:20)
at Redis.<anonymous> (C:\Users\Meroper80\Documents\GitHub\DndBot\Node-Js-Discord-Bot\node_modules\#keyv\redis\src\index.js:17:38)
at Redis.emit (events.js:315:20)
at Redis.silentEmit (C:\Users\Meroper80\Documents\GitHub\DndBot\Node-Js-Discord-Bot\node_modules\ioredis\built\redis\index.js:499:26)
at Socket.<anonymous> (C:\Users\Meroper80\Documents\GitHub\DndBot\Node-Js-Discord-Bot\node_modules\ioredis\built\redis\event_handler.js:186:14)
at Object.onceWrapper (events.js:422:26)
at Socket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 6379
}
I'm not sure what this error is about, can someone help me?
I am sending emails using AWS SES. It was working fine, but recently I am getting Networking errors. Full stack track is as followling.
Error: write EPROTO 140495130142528:error:140770FC:SSL
routines:SSL23_GET_SERVER_HELLO:unknown
protocol:../deps/openssl/openssl/ssl/s23_clnt.c:827:
at _errnoException (util.js:1022:11)
at WriteWrap.afterWrite [as oncomplete] (net.js:880:14)
message: 'write EPROTO 140495130142528:error:140770FC:SSL
routines:SSL23_GET_SERVER_HELLO:unknown
protocol:../deps/openssl/openssl/ssl/s23_clnt.c:827:\n',
code: 'NetworkingError',
errno: 'EPROTO',
syscall: 'write',
region: 'us-east-1',
hostname: 'email.us-east-1.amazonaws.com',
retryable: true,
time: 2018-07-26T09:57:44.096Z
I am also getting following error.
TimeoutError: Connection timed out after 120000ms
at ClientRequest.<anonymous> (/var/runtime/node_modules/aws-
sdk/lib/http/node.js:83:34)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:106:13)
at ClientRequest.emit (events.js:208:7)
at TLSSocket.emitTimeout (_http_client.js:711:34)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:106:13)
at TLSSocket.emit (events.js:208:7)
at TLSSocket.Socket._onTimeout (net.js:420:8)
at ontimeout (timers.js:482:11)
message: 'Connection timed out after 120000ms',
code: 'TimeoutError',
time: 2018-07-26T10:09:31.149Z,
region: 'us-east-1',
hostname: 'email.us-east-1.amazonaws.com',
retryable: true
How to resolve this issue?
I have the follow backend Node.js code to connect to my Stripe account to make a Charge. But I'm getting this error. I'm using Firebase Functions, and this functionality used to work before, so I doubt this is anything to do with Firebase access restrictions. Any ideas and help on this will be greatly appreciated!
var functions = require('firebase-functions');
var stripe = require('stripe')('sk_test');
var express = require('express');
var bodyParser = require('body-parser');
var cors = require('cors');
exports.stripePay = functions.https.onRequest((request, response) => {
if (request.method === 'POST') {
var app = express();
var router = express.Router();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cors());
var stripetoken = request.body.cardToken;
var amountpayable = request.body.amount;
var charge = stripe.charges.create({
amount: amountpayable,
currency: 'usd',
source: stripetoken,
description: 'Sample transaction'
}, function (err, charge) {
console.log("ST4");
if (err) {
response.send("Failed!");
}
else {
response.send({ success: true });
}
})
}
{ Error: An error occurred with our connection to Stripe
at Error._Error (/user_code/node_modules/stripe/lib/Error.js:12:17)
at Error.Constructor (/user_code/node_modules/stripe/lib/utils.js:98:13)
at Error.Constructor (/user_code/node_modules/stripe/lib/utils.js:98:13)
at ClientRequest.<anonymous> (/user_code/node_modules/stripe/lib/StripeResource.js:192:9)
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) type: 'StripeConnectionError', stack: 'Error: An error occurred with our connection to Stripe\n at Error._Error (/user_code/node_modules/stripe/lib/Error.js:12:17)\n at Error.Constructor (/user_code/node_modules/stripe/lib/utils.js:98:13)\n at Error.Constructor (/user_code/node_modules/stripe/lib/utils.js:98:13)\n at ClientRequest.<anonymous> (/user_code/node_modules/stripe/lib/StripeResource.js:192:9)\n at emitOne (events.js:96:13)\n at ClientRequest.emit (events.js:188:7)\n at TLSSocket.socketErrorListener (_http_client.js:310:9)\n at emitOne (events.js:96:13)\n at TLSSocket.emit (events.js:188:7)\n at connectErrorNT (net.js:1020:8)\n at _combinedTickCallback (internal/process/next_tick.js:74:11)\n at process._tickDomainCallback (internal/process/next_tick.js:122:9)', rawType: undefined, code: undefined, param: undefined, message: 'An error occurred with our connection to Stripe', detail: { Error: getaddrinfo ENOTFOUND api.stripe.com api.stripe.com:443
at errnoException (dns.js:28:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
code: 'ENOTFOUND',
errno: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'api.stripe.com',
host: 'api.stripe.com',
port: '443' }, raw: { message: 'An error occurred with our connection to Stripe',
detail:
{ Error: getaddrinfo ENOTFOUND api.stripe.com api.stripe.com:443
at errnoException (dns.js:28:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
code: 'ENOTFOUND',
errno: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'api.stripe.com',
host: 'api.stripe.com',
port: '443' } }, requestId: undefined, statusCode: undefined } Reply
this is a good one! Firebase blocks external API connections for Free accounts, just get any paid account and this will work!
Dimitris answer is correct, in more layman's terms simply get on the blaze plan and you can make calls to stripe api from Firebase Functions.
The error is as shown below:
{ RequestError: Error: connect ECONNREFUSED 127.0.0.1:8200
at new RequestError (C:\Users\anand\quFlipApi\node_modules\request-promise\lib\errors.js:11:15)
at Request.RP$callback [as _callback] (C:\Users\anand\quFlipApi\node_modules\request-promise\lib\rp.js:60:32)
at self.callback (C:\Users\anand\quFlipApi\node_modules\request\request.js:188:22)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at Request.onRequestError (C:\Users\anand\quFlipApi\node_modules\request\request.js:884:8)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at Socket.socketErrorListener (_http_client.js:310:9)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at emitErrorNT (net.js:1276:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)
name: 'RequestError',
message: 'Error: connect ECONNREFUSED 127.0.0.1:8200',
cause:
{ Error: connect ECONNREFUSED 127.0.0.1:8200
at Object.exports._errnoException (util.js:1026:11)
at exports._exceptionWithHostPort (util.js:1049:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1085:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 8200 },
error:
{ Error: connect ECONNREFUSED 127.0.0.1:8200
at Object.exports._errnoException (util.js:1026:11)
at exports._exceptionWithHostPort (util.js:1049:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1085:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 8200 },
options:
{ method: 'PUT',
path: '/sys/init',
json: { secret_shares: 1, secret_threshold: 1 },
headers: { 'X-Vault-Token': undefined },
uri: 'http://127.0.0.1:8200/v1/sys/init',
simple: false,
resolveWithFullResponse: true,
callback: undefined,
transform: undefined },
response: undefined }
Connection with database succeeded.
The code for that is as shown below:
app.js
var options = {
apiVersion: 'v1', // default
endpoint: 'http://127.0.0.1:8200' // default
};
// get new instance of the client
var vault = require("node-vault")(options);
// init vault server
vault.init({ secret_shares: 1, secret_threshold: 1 })
.then((result) => {
var keys = result.keys;
// set token for all following requests
vault.token = result.root_token;
// unseal vault server
return vault.unseal({ secret_shares: 1, key: keys[0] })
})
.catch(console.error);
I have already removed clienttoken field to avoid any complexity, but still it is giving me the error.In this above code should I enter /remove any other field to make it work ?