libp2p / go-libp2p-examples

Example libp2p applications
MIT License
339 stars 145 forks source link

Content Discovery (Advertise/FindPeers) Finding 0 peers #171

Open alabianca opened 4 years ago

alabianca commented 4 years ago

Hi, Thanks for all the examples. They help a lot. I am running into an issue where I am trying to run the chat-with-rendezvous examples on 2 machines. Both machines connect to the bootstrap peers just fine and both advertise the meet me here rendezvous string. However, when using FindPeers I get back 0 peers. The example only works if i run both peers on the same machine or on the same network.

Some friends and I are trying to learn more about libp2p by building a dummy app that advertises file hashes via discovery.Advertise and find them using discovery.FindPeers . However, we run into the above issue as we sit behind NATs. Once we do have the peer ID we know how to connect to each other using circuit-relay. Its just a matter of discovering the peer that advertises the hash which blocks us at the moment.

t-lin commented 4 years ago

I ran into this issue a while ago and root-caused it to changes in the kad DHT package sometime after v0.5.0. The default mode of DHTs used to be "server", now the default is just a client (they can query, but not respond). The fix was to add the dht.Mode(dht.ModeServer) option as a parameter when calling dht.New().

alinturbut commented 4 years ago

@t-lin thanks, that solved our issue as well! the examples / documentation need to be updated!