Firebase Cloud Functions: Error: Unexpected error getting default application credentials: read ECONNRESET

When I tried to run the cloud-based firebase function using the http trigger, I continued to get this error, but only periodically:

Error: Unexpected error while acquiring application default credentials: read ECONNRESET 

There are some unrelated ECONNRESET / firebase SO answers that did not provide a solution: Firebase Storage and Cloud Functions - ECONNRESET

+4
source share
1 answer

Problem:

To initialize my functions, I used:

const functions = require('firebase-functions');
const admin = require('firebase-admin');    

admin.initializeApp(functions.config().firebase);

Solution (for me at least):

I had to use the credentials of a Google service account:

var serviceAccount = require("./PATH_TO_YOUR_SERVICE_ACCOUNT_FILE_GOES_HERE.json");

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: "https://YOUR_FIREBASE_PROJECT_NAME.firebaseio.com"
});

To get the name of the firebase project, check the top left corner of the project console () A Firebase.

JSON, (B) firebase, (C) :

enter image description here

:

enter image description here

" ", .

JSON , .

enter image description here

+2

Source: https://habr.com/ru/post/1692113/


All Articles