orbitdb / field-manual

The Offical User's Guide to OrbitDB
207 stars 43 forks source link

How Peer discovery works? #52

Open adamskrodzki opened 4 years ago

adamskrodzki commented 4 years ago

Hi, I've tried to play around with this tutorial and modify the code https://gateway.pinata.cloud/ipfs/QmZYWWiXpEJXm9neWFpHEHBc5YbQFTFkS4yL777eG64y1r/

first I've changed config this.defaultOptions = { accessController: { write: ['*'] }}

so everyone connects to databese of the same Id and have write permissions on it.

I also configured IPFS as follows:

this.node = new IPFS({ relay: { enabled: true, hop: { enabled: true, active: true } }, preload: {enabled:true}, repo: './ipfs', EXPERIMENTAL: { pubsub: true } })

Now when I open this website in two windows (one of them incognito) and I call const peers = await this.node.swarm.peers() I see both nodes connected to same 8 peers (for example "QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd" )

Now on one page i call
NPP.addNewPiece("abc","xyz")

there is no data on other window

If i connect two peers directly NPP.connectToPeer("QmU4Qxk7zeZmoHJZddA672ku9DXRK76j4gAxU1HSF97grt")

messages starts floating from one node to another

my question is, why this 8 initial peers do not relay messages?

how can I discover others peers to connect to them ?

If there is houdrets or thousands of concurrent users viewing same page I guess browser do not have resources to connect to all new users. Should I manuall choose which peers to connect to?

julienmalard commented 2 years ago

Hello, A bit late to reply, butt I've just found a solution to a similar problem - try setting up a free WebRTC star process on Heroku https://dev.to/suda/spinning-up-a-free-ipfs-webrtc-star-discovery-server-with-heroku-284p Connections then work (for me at least).