Skip to content

Firebase Config Node ​

Overview ​

The Firebase Config node is a configuration node: it does not appear in the palette and processes no messages. It signs in to a Rosepetal Firebase project with a user's email and password, keeps the list of datasets and models of that project in memory, and shares that connection with the nodes that reference it.

Key Features ​

  • Two ways to give credentials: a JSON file on the Node-RED host (the default) or fields typed in the dialog
  • Live dataset and model lists: Firestore listeners reload them when the project changes
  • Automatic reconnection: exponential backoff, and a health check every 60 seconds
  • Fetch limit: at most 5000 image downloads per 24 hours through one connection

Configuration ​

PropertyDefaultMeaning
NameemptyLabel of the node; firebase-config when empty
ModeCredentials fileCredentials file reads the credentials from a file on the Node-RED host; Inline credentials takes them from the three fields below
Credentials path/opt/storage/credentials/firebase-credentials.jsonFile mode. Absolute path of the credentials file. It is read again on every connection and reconnection
EmailemptyInline mode. Email of a user of the Firebase project
PasswordemptyInline mode. Password of that user
Firebase ConfigemptyInline mode. The web app configuration of the Firebase project, as JSON. The editor marks it invalid unless it has apiKey, authDomain, projectId, storageBucket, messagingSenderId and appId

The email and password are those of a Firebase Authentication user of the project (email/password sign-in), not of a service account.

Credentials file ​

json
{
  "email": "line-controller@example.com",
  "password": "********",
  "config": {
    "apiKey": "AIzaSy...",
    "authDomain": "project-id.firebaseapp.com",
    "projectId": "project-id",
    "storageBucket": "project-id.appspot.com",
    "messagingSenderId": "123456789",
    "appId": "1:123456789:web:abcdef"
  }
}

email, password and config are required; config can also be the same object as a JSON string. When the node is saved in file mode, the editor clears the inline fields, so no credential is kept in the flow file. In inline mode the email, password and Firebase config are saved in the flow file (flows.json).

How to Get Firebase Credentials ​

  1. Go to Firebase Console
  2. Select your project
  3. Go to Project Settings (gear icon)
  4. Scroll to "Your apps" section
  5. Click on your web app or create one
  6. Copy the Firebase configuration object

Configuration Steps ​

  1. Add a firebase-config node from the Firebase field of a node that uses it (for example list-dataset).
  2. Choose the mode and fill the path or the three inline fields.
  3. Click Connect to check the credentials. Before the first deploy the dialog answers POSSIBLE CONNECTION ⬆️ Instantiate before configuring other nodes.: the credentials work, and the node starts using them once deployed.
  4. Deploy, then select this configuration in the other nodes.

Editor Dialog ​

Besides the fields, the dialog shows:

  • Firebase connection: CONNECTED ✅, NOT CONNECTED ❌ or Node not instantiated 🟡 (saved but not deployed yet). Next to it, Connect signs in with the values in the dialog; once connected the button becomes Refresh, which reloads every dataset and model from Firebase. A failed connection shows a notification Error connecting to Firebase: <reason>.
  • Fetch limit: the image downloads counted in the current window, as count / 5000, followed by — LIMIT REACHED when the limit is hit and · resets in <time>. Restart limit sets the counter back to zero after a confirmation (see Fetch limit).

Connection ​

On deploy the node reads the credentials, signs in to Firebase Authentication, then:

  1. Loads the datasets and the image count of each of their tags (30 second limit).
  2. Starts a Firestore listener on the datasets.
  3. Loads the models (15 second limit).
  4. Starts a Firestore listener on the models.

Then the connection is up. Every 60 seconds a health check asks Firestore to count the datasets (10 second limit).

Reconnection ​

A failed connection is retried after 2 seconds, then 4, 8, 16 and so on up to 60 seconds between attempts, with ±10 % jitter, until it works or the node is stopped. A failed health check, a listener error, or an authentication error while loading datasets or models closes the session and starts the same retry loop.

An unreadable or incomplete credentials file is not retried: the node logs Credentials error: <message> and stays disconnected until it is deployed again. The messages are:

  • Cannot read credentials file <path>: <reason>
  • Credentials file <path> is not valid JSON: <reason>
  • Credentials file <path> missing required fields (email, password, config)

Other errors are retried; the most common are Invalid Firebase config JSON: <reason> and Firebase initialization failed: <Firebase error> (for example a wrong password).

Status in the nodes that use it ​

list-dataset and list-model show the state of the connection as their status:

StatusMeaning
yellow dot connecting or connecting (attempt N)Signing in, or retrying after attempt N failed
green dot connectedConnected
red ring with the error textAn attempt failed; a new one follows
yellow ring waiting for firebaseNot connected, or the connection was closed

The other nodes show their own status texts, described on their pages.

Data Synchronization ​

Datasets ​

The node keeps every document of the project's dataset collection that has a type and is not deleted or hidden, keyed by document id, with:

  • name (first letter in upper case), id and type
  • creation and update dates
  • tags: the number of images of each tag

A change in the collection reloads the whole list 1.5 seconds later; several changes in a row cause one reload.

Models ​

The node keeps every model whose status is finished, that is not deleted and has no finetuned field, keyed by document id, with id, status, fileUrls, createdAt, updatedAt, dataset (the dataset id), modelTask, classes and pipeline. Changes to finished models reload the list 1.5 seconds later.

Connection events ​

The config node emits these events to the nodes of this package that listen to it (they cannot be used from a function node):

EventWhen
firebase-connectingAn attempt starts, with the attempt number
firebase-connectedThe connection is up
firebase-connection-errorAn attempt failed, with the error text
firebase-disconnectedThe connection is closed
datasets-updatedThe dataset list was reset or reloaded
models-updatedThe model list was reset or reloaded
firebase-budget-resetThe fetch limit was restarted

Fetch Limit ​

Every image downloaded from Firebase Storage through the connection is counted; in this package that is every image read by from-dataset. Uploads and model downloads are not counted.

  • The window starts with the first download and lasts 24 hours; then the counter goes back to zero.
  • At 4000 downloads (80 %) the node warns Firebase fetch budget at 80% (4000/5000).
  • Download 5001 fails with Firebase fetch budget reached (5001/5000). Reset in firebase-config., and so does every later one until the window ends or the limit is restarted.
  • The counter is saved in ~/.node-red/rosepetal-vp-budget/ under the config node's id, so it survives restarts and redeploys. Deleting the config node deletes it.
  • Restart limit in the dialog sets the counter to zero, without a redeploy. What a blocked from-dataset node does then depends on its mode: see Fetch limit and disconnections.

Usage in Other Nodes ​

NodeFieldUses the connection to
dataset-uploadFirebase Config, requiredUpload images to a dataset
from-datasetFirebase configuration, requiredRead images of a dataset
list-datasetFirebase config, requiredList the datasets
list-modelFirebase config, requiredList the models
vlm-online-inferencerCredentials, requiredAuthenticate its requests
inferencerFirebase, optionalDownload models trained on the platform
triton-inferencerFirebase, optionalDownload and convert models trained on the platform
model-managerFirebase, optionalDownload models that are not on the controller yet

The OCR nodes do not use it.

Required Firebase Services ​

  • Firebase Authentication with email/password sign-in, and a user for Node-RED
  • Cloud Firestore, with the Rosepetal collections (dataset, its tag sub-collection, image, model)
  • Cloud Storage, where the images and the model files are

See Also ​