go-libp2p-examples
go-libp2p-examples copied to clipboard
chat-with-rendezvous: No way found to remove host from kad-dht
The default rendezvousString
did not work well for me.
Instead, I use a UUID as rendezvousString
and it did work better. But, after a restart, I get errors concerning the old peers:
-
dial attempt failed: <peer.ID Qm*QscaEK> --> <peer.ID Qm*dFxmP9> dial attempt failed: connection refused
-
dial backoff
Using a new UUID, there are no errors.
How can I remove peers from kadDht
? I tried it with contexts and methods, but without success. How can it be done?
@stefanhans So everyone trying this code by default are using meet me here
as the rendezvousString
.
So every time you run this code a new peer is started and it will announce itself (using Provide
) to the bootstrap node with rendezvous point meet me here
. But what happens once you disconnect?
Your address is still registered in the bootstrap node at that rendezvous point (till the time it expires and dht is forced to remove it) and anyone looking for new peers to connect (using FindProviders
) will get your address. Now bootstrap peers don't know if these address or peers are still alive. Now, when you try to connect to them you get dial attempt failed:
error.
Now, this is not your peers fault instead it's the bootstrap peer giving you dead peers. I don't think libp2p has any method which lets you remove peers from the bootstrap peer's list. It should be the bootstrap peer who should ping a remote node just to check if it is alive or dead and act accordingly. RFC: rendezvous is a more sophisticated rendezvous protocol which is better than the existing dht hack.
You might also notice that if you run a peer (let's say A) and announce yourself to the dht and now start another peer (say B) which queries the bootstrap peer for new addresses. All peers received by peer B are dead and none of the address corresponds to peer A. This happens because bootstrap peer returns a random subset of the peers registered with it.
So, it would be better to not use meet me here
instead use something unique and start two peers with the same rendezvousString
. For meet me here
to work you need more number of alive peers than the dead ones.
Hi @upperwal,
sounds reasonable 😀 thx
I ended up with using a UUID as rendezvous string. Still not always getting all peers connected in the prototype of mine.
Maybe SWIM(++) protocol from Hashicorp is worth a try.
Cheers, Stefan