question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Database wont sync after importing (web)

See original GitHub issue

After importing the initial_messages.json through the firebase console in the browser and adding the relevant code to main.js below:

// Loads chat messages history and listens for upcoming ones.
FriendlyChat.prototype.loadMessages = function() {
  // Reference to the /messages/ database path.
  this.messagesRef = this.database.ref('messages');
  // Make sure we remove all previous listeners.
  this.messagesRef.off();

  // Loads the last 12 messages and listen for new ones.
  var setMessage = function(data) {
    debugger // NOTE THE DEBUGGER HERE TO FREEZE PAGE IN CHROME DEV TOOLS
    var val = data.val();
    this.displayMessage(data.key, val.name, val.text, val.photoUrl, val.imageUrl);
  }.bind(this);
  this.messagesRef.limitToLast(12).on('child_added', setMessage);
  this.messagesRef.limitToLast(12).on('child_changed', setMessage);
};

the setMessage function is never called which means that the sample application is most likely not connected to the database online.

var config = {
    apiKey: "asdfasdfasdfasdfasdf",
    authDomain: "testapp-ed989.firebaseapp.com",
    databaseURL: "https://testapp-ed989.firebaseio.com", // I've checked this url is the same
    storageBucket: "testapp-ed989.appspot.com",
  };
  firebase.initializeApp(config);

I’ve initialized firebase in the bottom of my index.html within a <script> and in the database tab of my console, the url is https://testapp-ed989.firebaseio.com/ which is the same as in my config.

The only thing that I’m not sure about is the database configurations which I dont think does anything different about connecting to the database as long as I’m logged in.

{
  "rules": {
    "users": {
      "$uid": {
        ".read": "$uid === auth.uid",
        ".write": "$uid === auth.uid"
      }
    }
  }
}

image

The imported messages wont display regardless of how many times I reload/re-serve/deploy.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
nicolasgarniercommented, Aug 24, 2016

It’s very strange because by default, on new projects, the Database rules are:

{
  "rules": {
    ".read": "auth != null",
    ".write": "auth != null"
  }
}

Which should work for the code. Step 9 is actually an optional step for that reason (the app would still work the same if you skipped it). For example could you try to revert the rules to the rules above? Things should still work.

0reactions
JeffreyCheng92commented, Aug 24, 2016

Okay I see the issue here now. It wasn’t the tutorials fault at all but when I went to import the initial_messages.json it said the rules had to be changed before the database could be used.

image

which led me to copy this in my database.rules.json as well as in the online rules.

image

Thanks for clearing all of this up!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Synchronization problems in Outlook and OWA - Microsoft Learn
To do this, follow these steps: Right-click the folder, and then select Properties. Select Clear Offline Items, and then select OK.
Read more >
Troubleshoot sync errors - Abstract
Sync errors are sometimes caused by problems with your network or internet connection. Try the following steps to check your connection.
Read more >
Data import issues - Google Workspace Learning Center
Here's how to troubleshoot problems you might have when using Google Workspace Sync for Microsoft Outlook (GWSMO) to import data to your Google...
Read more >
Import data into Notion – Notion Help Center
Like most people, you probably have data, documents, and notes scattered across many files and ... Notion lets you directly import the following...
Read more >
Troubleshooting for Amazon RDS
When you can't connect to a DB instance, the following are common causes: ... Amazon RDS doesn't accept internet control message protocol (ICMP)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found