Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FAQ: Database replication is not working #64

Open
haadcode opened this issue Nov 20, 2018 · 5 comments
Open

FAQ: Database replication is not working #64

haadcode opened this issue Nov 20, 2018 · 5 comments
Labels

Comments

@haadcode
Copy link
Member

This is probably the most frequently asked question and it needs canonical answer as well as detailed "troubleshooting" steps as the reasons seem to vary. However, there are two major ones that I seen constantly popping up: using orbitdb in app code (eg. calling load() or listening for replicated event) and IPFS problems (which can be due to many reasons).

Leaving this open to collect all the relevant issues and answers as I'm pretty sure this has been answered in the past by multiple people to multiple questions around the topic.

Would love comments and contributions to link to the issues or a PR to gather the information to a document directly.

Possibly related issues orbitdb/orbitdb#264, orbitdb/orbit-db#349, orbitdb/orbitdb#315 and orbitdb/orbit-db#442. There may be others.

@christroutner
Copy link

christroutner commented Nov 23, 2018

I ran into this same problem, trying to get a DB to replicate across IPFS nodes running the node.js implementation of js-IPFS and Orbit-DB. I was trying to get a locally running node.js app (Node A) to talk with another peer running in a Virtual Machine (VM) (Node B). They did not appear to be communicating and the DB was not getting replicated. Here is how I went about debugging.

I started by adding an console.log alert whenever the replication event fired:

db.events.on('replicated', () => {
  console.log(`replication event fired`)
})

Running the software again, I could see that the replication event never fired.

I set up a third node on a Digital Ocean Droplet cloud server (Node C). After running the software I could also see the replication event was not firing. I copied the multiaddr for Node C and added it to the first two nodes with this code:

ipfs.bootstrap.add('/ip4/162.243.158.213/tcp/4002/ipfs/QmQLcCWKuxsMkRt5DJkcSw361iNLikjEBMEj6ovR6pwAb5')

I was able to ensure that Node C was in the bootstrap list with this command:

const list = await ipfs.bootstrap.list()
console.log(`list: ${util.inspect(list)}`)

As soon as I added the bootstrap.add code to the other two nodes and started them all, the replication event immediately started firing and the DB started getting replicated across the nodes.

RichardLitt referenced this issue in orbitdb/orbitdb Nov 26, 2018
@christroutner
Copy link

To help myself understand the intricacies of libp2p and orbit-db replication, I created this db-replication directory in a repo I created for such things:
https://github.com/christroutner/orbit-tests/tree/master/db-replication

Check out the README in that folder. It describes the various network configurations. The code is currently replicating the example database across firewalled peers.

@aphelionz
Copy link
Member

@christroutner That is super cool - do you want to add that repo to the https://github.com/orbitdb/awesome-orbitdb repo in the Tools section?

@aphelionz
Copy link
Member

Moving this to the Field Manual Repo

@aphelionz aphelionz transferred this issue from orbitdb/orbitdb Sep 27, 2019
@melroy89
Copy link

Can the answer be updated already on https://github.com/orbitdb/orbit-db/blob/master/FAQ.md#database-replication-is-not-working-why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants