Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect 2 peers behind the NAT #44

Closed
personstays opened this issue Mar 5, 2018 · 1 comment
Closed

Connect 2 peers behind the NAT #44

personstays opened this issue Mar 5, 2018 · 1 comment

Comments

@personstays
Copy link

personstays commented Mar 5, 2018

Hello,

Thanks for this good project. I have been trying to use this project to test the peer to peer discovery. I have the following setup. (2 nodes over NAT and one Non-NATed bootstrap node)

  • A public ip (vps on DigitalOcean) as a Bootstrap Node with the following code:
import logging
import asyncio

from kademlia.network import Server

handler = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
log = logging.getLogger('kademlia')
log.addHandler(handler)
log.setLevel(logging.DEBUG)

server = Server()
server.listen(8468)

loop = asyncio.get_event_loop()
loop.set_debug(True)

try:
    loop.run_forever()
except KeyboardInterrupt:
    pass
finally:
    server.stop()
    loop.close()
  • Computer A behind NAT (at office) which bootstrap from public ip at DigitalOcean with the following code:
import logging
import asyncio

from kademlia.network import Server

handler = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
log = logging.getLogger('kademlia')
log.addHandler(handler)
log.setLevel(logging.DEBUG)

server = Server()
server.listen(8468)

loop = asyncio.get_event_loop()
loop.set_debug(True)
loop.run_until_complete(server.bootstrap([("<public ip from DigitalOcean>", 8468)]))

try:
    loop.run_forever()
except KeyboardInterrupt:
    pass
finally:
    server.stop()
    loop.close()
  • Computer B behind NAT (at home) with the same source code as Computer A.

Those 2 nodes could connect the bootstrap node. My problem is that I can't make those 2 nodes to connect to each other through bootstrap node.

In Computer B - The response was kademlia.protocol - WARNING - no response from <Computer A's NAT's external IP>:46357, removing from router

In Computer A - Vice versa

Since I'm new to "P2P Network" (Kademlia), perhaps I missed or did something wrong. I've tried to search for the answers on the internet for many days, but no luck. There aren't many documents about this problem either.

Could you help guide me how to connect those 2 nodes over NAT? Or source code would be highly appreciated.

Thanks!

@bmuller
Copy link
Owner

bmuller commented Mar 7, 2018

If both machines are behind a NAT, then UDP hole punching won't work and the two machines won't be able to talk to each other. Eventually, we could come up with a way of coordinating mutual hole punching using a coordination node, but that would require a lot of work.

@bmuller bmuller closed this as completed Mar 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants