libp2p / go-libp2p-kad-dht

A Kademlia DHT implementation on go-libp2p
https://github.com/libp2p/specs/tree/master/kad-dht
MIT License
519 stars 222 forks source link

Cannot find any peers in table when host not previously connected #308

Open hsanjuan opened 5 years ago

hsanjuan commented 5 years ago

I have an rather annoying issue:

If I create an IpfsDHT on an empty Host, then I create a second Host and connect them, Bootstrapping the DHT does not seem to work (get things like `failed to find any peer in table).

Bootstrapping only works if the Host was already connected to some other peer at the moment the DHT is created, and not at the moment it is asked to bootstrap (or runs a bootstrap round).

I would expect that running BootstrapOnce (or letting the default bootstrap ticker happen) would take into account the newly added peer connections after the DHT itself was created.

Let me know if I haven't explained myself clearly. Is there a workaround for this perhaps?

Stebalien commented 5 years ago

This may be a race. When you ask the DHT to bootstrap, it may not yet have finished probing those new peers. If you've already added those peers, we've probably finished running the identify protocol. In this case, we may need to try "bootstrapping" with our current peer list.

anacrolix commented 5 years ago

This is strongly related to #283 and #295.