Peer Discovery with Kademlia #5488
-
Hello, I am new to the project. I am working on peer discovery with Kademlia. I have three different nodes; Node A and Node B -> worker nodes on a different server Bootstrap Node -> My node running separately, with an open port. Node A and Node B are listening on port *4001 and I give the bootstrap node to both nodes. The situation is as follows; the messages I send from Node A or B are forwarded to each other. In the same way, Bootstrap node finds both nodes as peers and adds them to the Routing Table. But Node A and Node B cannot add each other to the routing table.
Since the bootstrap node is given as multiaddr, it dials from the public ID of the bootstrap node, but when dialing to the node to which Bootstrap is connected, is dialed from the local address. What could be the problem? Here is my code;
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Welcome to libp2p @anilaltuner! The solution is certainly to put the Kademlia nodes in server modes, so that they add each other to their routing tables. See this similar issue and let me know if the suggested solution doesn't work. |
Beta Was this translation helpful? Give feedback.
-
Thanks @guillaumemichel! I did but one thing for sure, I saw they add each other but cannot dial themselves and they simply can't peered each other probably cause of ports are closed. Am I need implement nat traversal for it? |
Beta Was this translation helpful? Give feedback.
-
Sorry, I missed it. What is your network setup? Do you run all nodes within the same network? Are the nodes hosted in a public could/home network/other? Is there a firewall in place?
Is the Could you also share the full output (incl. showing that the nodes A and B don't connect to each other)? |
Beta Was this translation helpful? Give feedback.
Do you mean that you don't have connectivity issues when you open the port 4001 for Node A? If that is the case, then the problem doesn't come from Kademlia but from your network connectivity.
If you don't want to open the port, I suggest you look into UPnp and DCUtR, you can learn more about libp2p NAT Traversal here.