Debugging firebase RT database connection

Viewed 13

I'm following this tutorial on building in-app presence using cloud firestore and they recommend using Firebase realtime database. The relevant bit of code for this question is:

database.onValue(database.ref(db, '.info/connected'), function (snapshot) {
    if (snapshot.val() == false) {
        // Instead of simply returning, we'll also set Firestore's state
        // to 'offline'. This ensures that our Firestore cache is aware
        // of the switch to 'offline.'
        console.log('not connected to rtdb');
        firestore.setDoc(userStatusFirestoreRef, isOfflineForFirestore);
        return;
    };
    userStatusDatabaseRef.onDisconnect().set(isOfflineForDatabase).then(function () {
        console.log('connected to rtdb');
        userStatusDatabaseRef.set(isOnlineForDatabase);
        // We'll also add Firestore set here for when we come online.
        firestore.setDoc(userStatusFirestoreRef, isOnlineForFirestore);
    });
});

The line not connected to rtdb consistently prints to my console, but I haven't seen connected to rtdb once. Is there an additional step I need to do to establish a connection to the realtime database?

0 Answers
Related