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

Cannot connect peers behind NAT #16

Open
gerhardberger opened this issue Jan 7, 2017 · 11 comments
Open

Cannot connect peers behind NAT #16

gerhardberger opened this issue Jan 7, 2017 · 11 comments

Comments

@gerhardberger
Copy link

I'm trying to use discovery-swarm with hyperdrive. On a local network the peers successfully find each other, but if I try to connect to a peer and we both behind NAT, they won't find each other.

I use the servers used in datland-swarm-defaults.

How you supposed to connect in this case? I'm quite new to these things so maybe I'm missing something.

@okdistribute
Copy link
Collaborator

Take a look at the implementation in the 'hyperdiscovery' module, do you still have issues connecting using that?

Curious also if you can run the 'p2p-test' cli tool on your machine?

@gerhardberger
Copy link
Author

As I can see hyperdiscovery is a simplification of discovery-swarm with datland-swarm-defaults. The p2p-test gave this back:

{
  time: '2017-01-07T23:52:17.908Z',
  description: '',
  holePunchable: true,
  pings: 
   [ { port: 53271, host: '79.122.53.42' },
     { port: 53271, host: '79.122.53.42' } ]
}

I found though that the issue might be that I need some sort of hole punching mechanism in order to connect, but as far as I see discovery-channel's dht and dns methods cannot do that. I need turn or stun servers for that. I see that bittorrent-tracker can do that so I was thinking about adding it to discover-channel as a third peer discovery mechanism. What are your thoughts on that?

@samuelmaddock
Copy link

samuelmaddock commented Jan 13, 2018

I'm experiencing similar issues with this test script I wrote. The peer address is found through the DHT, but no connection is established.

I've been testing communication between a Windows 10 and macOS High Sierra machine.

@samuelmaddock
Copy link

After some more debugging, I found that remote peers only seem to connect to each other over uTP when opts.announce is passed into sw.join on both ends.

@skerit
Copy link

skerit commented Mar 14, 2018

I'm still having this issue. I use both DHT & DNS (also using the datland-swarm-defaults), but clients behind NAT can't connect.

In my non-nat machine I see incoming connections that have a host like '192.168.1.60', from an outside network. So something's going wrong there.

@DennisSchwartz
Copy link

I have the same problem when using DAT/Hyperdrive in Docker. I have exposed the ports and peers get discovered but dropped after 4 failed connection attempts.

I have tried creating the connection manually on both ends using opts.announce but I get the same issue.

@samuelmaddock can you elaborate a little about how you solved the issue if you did?

Thanks!

@samuelmaddock
Copy link

@skerit @DennisSchwartz I wrote a module using discovery-swarm to connect peers to a host, swarm-peer-server. It has an echo server example you could try using to test if peers connect: https://github.com/samuelmaddock/swarm-peer-server/blob/master/examples/echo.js

Also, you should use dat-swarm-defaults, not datland-swarm-defaults.

@DennisSchwartz
Copy link

Awesome, thanks! I'll have a look at that.

@mjp0
Copy link

mjp0 commented Aug 6, 2018

I'm having same problem as @DennisSchwartz with Docker and 4 retries. I have tried few different network configurations with Docker including host option (which should in theory not have NAT problems at all but no help).

Using dat-swarm-defaults.

Has anybody got swarm working inside a Docker container?

@DennisSchwartz
Copy link

DennisSchwartz commented Aug 6, 2018

@0fork Sorry for committing the internet crime of not posting my solution after finding one - kinda.

First of all, I couldn't run it in a docker container locally.
HOWEVER: When running the container in Kubernetes, it magically works. I didn't have time yet to properly investigate why.

So my current workaround is to just run it in our cluster, and use Minikube for local development (which is a bit of a pain tbh).

Hope this helps.

@mjp0
Copy link

mjp0 commented Aug 18, 2018

I wanted to link my issue here from mafintosh/hypercore-multicast-swarm#1 multicast-swarm because it solved my NAT issue. The issue is that it supports only hypercore at the moment but I'm lacking skills to make it support hyperdb.

All help appreciated!

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

6 participants