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
| Property | Default | Meaning |
|---|---|---|
| Name | empty | Label of the node; firebase-config when empty |
| Mode | Credentials file | Credentials 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.json | File mode. Absolute path of the credentials file. It is read again on every connection and reconnection |
| empty | Inline mode. Email of a user of the Firebase project | |
| Password | empty | Inline mode. Password of that user |
| Firebase Config | empty | Inline 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
{
"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
- Go to Firebase Console
- Select your project
- Go to Project Settings (gear icon)
- Scroll to "Your apps" section
- Click on your web app or create one
- Copy the Firebase configuration object
Configuration Steps
- Add a firebase-config node from the Firebase field of a node that uses it (for example list-dataset).
- Choose the mode and fill the path or the three inline fields.
- 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. - Deploy, then select this configuration in the other nodes.
Editor Dialog
Besides the fields, the dialog shows:
- Firebase connection:
CONNECTED ✅,NOT CONNECTED ❌orNode 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 notificationError connecting to Firebase: <reason>. - Fetch limit: the image downloads counted in the current window, as
count / 5000, followed by— LIMIT REACHEDwhen 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:
- Loads the datasets and the image count of each of their tags (30 second limit).
- Starts a Firestore listener on the datasets.
- Loads the models (15 second limit).
- 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:
| Status | Meaning |
|---|---|
yellow dot connecting or connecting (attempt N) | Signing in, or retrying after attempt N failed |
green dot connected | Connected |
| red ring with the error text | An attempt failed; a new one follows |
yellow ring waiting for firebase | Not 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):
| Event | When |
|---|---|
firebase-connecting | An attempt starts, with the attempt number |
firebase-connected | The connection is up |
firebase-connection-error | An attempt failed, with the error text |
firebase-disconnected | The connection is closed |
datasets-updated | The dataset list was reset or reloaded |
models-updated | The model list was reset or reloaded |
firebase-budget-reset | The 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
| Node | Field | Uses the connection to |
|---|---|---|
| dataset-upload | Firebase Config, required | Upload images to a dataset |
| from-dataset | Firebase configuration, required | Read images of a dataset |
| list-dataset | Firebase config, required | List the datasets |
| list-model | Firebase config, required | List the models |
| vlm-online-inferencer | Credentials, required | Authenticate its requests |
| inferencer | Firebase, optional | Download models trained on the platform |
| triton-inferencer | Firebase, optional | Download and convert models trained on the platform |
| model-manager | Firebase, optional | Download 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, itstagsub-collection,image,model) - Cloud Storage, where the images and the model files are