No addresses of peer after successful kademlia lookup? #5371
-
I am trying to do a seemingly very simple thing: look up a peer in kademlia DHT, and dial it. I have noticed though that sometimes despite the kad query being successful, I am unable to dial the peer due to lack of known addresses. I would expect kad behaviour to be able to provide the peer's address via So e.g. I get this event:
And right after this I see:
How is that possible? Is this a bug or do I need to do something more in my code? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 13 replies
-
I've seen this when the node is in client mode. By default, the mode is automatically set on if an external address is provided. If none is provided, mode will be set to client mode, making it unable to accept queries, however once an external address is provided, either manually (either through |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
It is likely that the bucket to which the target peer belong is already full, so the addresses aren't stored in the
kad
routing table.This is indeed a serious issue.
I can see two ways to address it:
Peerstore
(see #4103)FromSwarm::NewExternalAddrOfPeer
event (context in #4371). This event could be emitted either a) for the target of theFIND_NODE
RPC only or b) for all discovered peers in a request (probably overkill). The caller of the kademlia lookup then needs to handle the addresses.The
Peerstore
seems to be the right approach, although it may not be straightforward to implement. Emitting aFromSwarm::NewExternalAddrOfPeer
event could be a temporary quick fix.