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:
- Using get-port module (Finding open ports) and
getPort().then(port => {
- 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.