0

I'm working with node.js looking to build a chat application with p2p capabilities.

I have 2 seporate computers on 2 different wifi networks.

I'm using the module fully-connected-topology and adding users to the topology using t.add(IP:PORT)

I'm getting the IP using the public-ip module and publicIp.v4().then(ip => { (Gets external IP)

I've tried getting the port in 2 ways:

  1. Using get-port module (Finding open ports) and getPort().then(port => {
  2. register-multicast-dns module and hash-to-port (I think this only works for local host so I switched to looking for open ports

Here's where I'm stuck:

Computer 1: IP = IP1, PORT = PORT1

Computer 2: IP = IP2, PORT = PORT2

when I run on Computer 1 t.add(IP2:PORT2) and on Computer 2 t.add(IP1:PORT1) no connection is made.

I know this because in this code:

t.on('connection', function (socket){
  console.log('Connection established') 
})

the print statement never fires.

Can someone direct me to where the packet is getting lost/dropped? It all worked when on the same network but I can't find where the error lies.

huddie96
  • 1,240
  • 2
  • 13
  • 26
  • Are the libraries you're using supposed to solve firewall problems associated with endpoints on different WiFi networks? – jfriend00 Apr 24 '18 at 01:16
  • @jfriend00 I was following a tutorial https://opbeat.com/community/posts/how-to-write-a-p2p-chat-app-in-nodejs-by-mathias-buus/ so i'm not sure. I'm not exactly sure what your question is asking since I'm a bit new to this. Your saying if a firewall blocks the income? Is there a different module that is better to use? – huddie96 Apr 24 '18 at 01:19
  • I'm referring to the general problem of two endpoints each on a private network. That means they both are behind firewalls and both have private IP addresses. Thus, they cannot just directly connect to one another. To make a peer-to-peer connection between them, one has to use a lot of specialized techniques. I'm asking if the libraries you are using are supposed to solve this problem for you or not? I'm sorry, but I'm not going to listen to that 40 minute video to find out what those modules are supposed to do. – jfriend00 Apr 24 '18 at 01:28
  • @jfriend00 Don't be sorry, wouldn't want you too, I don't think they deal with it. What are the techniques and are their different modules that deal with this stuff? – huddie96 Apr 24 '18 at 01:30
  • That's a long (and complicated) topic. For starters, see [If firewalls don't accept incoming connections by default do p2p networks work?](https://stackoverflow.com/questions/14926807/if-firewalls-dont-accept-incoming-connections-by-default-how-do-p2p-networks-wo). – jfriend00 Apr 24 '18 at 01:32
  • @jfriend00 Thanks, Ill look into it – huddie96 Apr 24 '18 at 01:48

0 Answers0