Skip to content

Firebase Config Node

Overview

The Firebase Config node is a configuration node that provides Firebase authentication and connection management for all Vision Platform nodes. It handles Firebase initialization, real-time data synchronization, and connection state management.

Key Features

  • Central configuration: Single source of Firebase credentials
  • Auto-reconnection: Handles connection failures gracefully
  • Real-time sync: Live updates for datasets and models
  • Connection events: Emits events for connection state changes
  • Credential validation: Validates Firebase config on startup
  • Model caching: Caches model information for performance
  • Dataset caching: Caches dataset metadata

Configuration

Firebase Credentials

Firebase configuration requires a JSON object with Firebase project credentials:

json
{
  "apiKey": "AIzaSy...",
  "authDomain": "project-id.firebaseapp.com",
  "projectId": "project-id",
  "storageBucket": "project-id.appspot.com",
  "messagingSenderId": "123456789",
  "appId": "1:123456789:web:abcdef"
}

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 firebase-config node (double-click in editor sidebar)
  2. Paste Firebase JSON configuration
  3. Click "Update" or "Add"
  4. Reference this config in other Vision Platform nodes

Connection States

States

StateDescription
disconnectedNot connected to Firebase
connectingAttempting connection
connectedSuccessfully connected
errorConnection failed

Connection Events

The node emits events that other nodes can listen to:

  • firebase-connecting: Connection attempt starting
  • firebase-connected: Successfully connected
  • firebase-disconnected: Connection lost
  • firebase-connection-error: Connection failed
  • datasets-updated: Dataset list changed
  • models-updated: Model list changed

Data Synchronization

Datasets

The config node automatically synchronizes dataset information:

  • Dataset names and IDs
  • Tag statistics (image counts per tag)
  • Dataset types (multiclass, multilabel, etc.)

Accessible via: firebaseNode.datasets

Models

The config node automatically synchronizes model information:

  • Model names and IDs
  • Associated datasets
  • Task types
  • Update timestamps

Accessible via: firebaseNode.models

Usage in Other Nodes

Referencing Config

All Vision Platform nodes have a "Firebase Config" dropdown:

  1. Select the firebase-config node you created
  2. Node will automatically connect
  3. Data available once connected

Example Nodes Using Firebase Config

  • Inferencer: Downloads models from Firebase
  • Dataset Upload: Uploads images to Firebase Storage
  • From Dataset: Streams images from Firebase
  • List Dataset: Lists available datasets
  • List Model: Lists available models

Error Handling

Common Errors

"Invalid Firebase configuration"

Cause: JSON config malformed or missing required fields

Solution:

  • Verify JSON is valid
  • Check all required fields present
  • Copy from Firebase Console directly

"Authentication failed"

Cause: Invalid API key or project permissions

Solution:

  • Verify API key is correct
  • Check Firebase project permissions
  • Regenerate API key if compromised

"Network error"

Cause: No internet connection or Firebase servers unreachable

Solution:

  • Check internet connectivity
  • Verify firewall settings
  • Check Firebase status page

Security Best Practices

  1. Protect credentials: Don't commit config to public repos
  2. Use environment variables: Store sensitive data separately
  3. Firestore security rules: Implement proper access controls
  4. API key restrictions: Restrict keys in Firebase Console
  5. Regular rotation: Update credentials periodically

Advanced Configuration

Multiple Environments

Create separate firebase-config nodes for different environments:

  • firebase-config-dev: Development environment
  • firebase-config-prod: Production environment

Switch configs based on deployment:

javascript
// In function node
const env = global.get("environment") || "dev";
msg.firebaseConfig = env === "prod" ? "firebase-config-prod" : "firebase-config-dev";
return msg;

Custom Event Handling

javascript
// In a function node that accesses the config node
const firebaseNode = RED.nodes.getNode("firebase-config-id");

firebaseNode.on("datasets-updated", (payload) => {
  node.warn(`Datasets updated: ${payload.datasetsCount} total`);
});

firebaseNode.on("firebase-connected", () => {
  node.warn("Firebase connected successfully");
});

Monitoring Connection Status

Visual Indicators

Nodes using Firebase config show connection status:

  • Yellow dot: Connecting
  • Green dot: Connected
  • Red ring: Error

Programmatic Check

javascript
// Function node
const firebaseNode = RED.nodes.getNode("firebase-config-id");

if (firebaseNode.connectionState === "connected") {
  msg.payload = "Firebase ready";
} else {
  msg.payload = "Firebase not ready";
}

return msg;

Troubleshooting

Connection takes long time

Possible causes:

  • Slow network
  • Large dataset/model lists
  • Firebase service issues

Solutions:

  • Check network speed
  • Monitor Firebase console
  • Wait for connection to complete

Frequent disconnections

Possible causes:

  • Unstable network
  • Firewall blocking connections
  • Token expiration

Solutions:

  • Check network stability
  • Configure firewall to allow Firebase
  • Verify credentials are valid

Data not syncing

Possible causes:

  • Firestore security rules blocking access
  • Permission issues
  • Collection structure changed

Solutions:

  • Review Firestore security rules
  • Check user permissions
  • Verify collection names

Required Firebase Services

The firebase-config node requires these Firebase services enabled:

  1. Firebase Authentication: User authentication
  2. Cloud Firestore: Database for datasets and models
  3. Cloud Storage: Image storage
  4. Firebase Realtime Database: Real-time updates (optional)

See Also