4

I want to create peer-to-peer connections between 2 nodejs client.

using websocket (dnode)

here is the limit:

  • nodejs client run at 2 pc which is in different network.
  • they don't have static ip (192.168.1.100 && 192.168.2.200) behind NAT or firewalls
  • no permission to change the mapping of router.
  • has only static web server in public network. (can change the file by human)
  • can install application at pc (win)

is it possible? thanks

atian25
  • 4,166
  • 8
  • 37
  • 60
  • No, you don't have a route between those two networks. You would have to reconfigure the NAT on the router, which you say you cannot do. – Brad Jul 06 '12 at 03:50
  • sad, no hope I think so... don't have a free node server account which support websocket – atian25 Jul 06 '12 at 03:54

2 Answers2

3

May be you can use PeerJS to achieve your objectives. PeerJS simplifies WebRTC peer-to-peer data, video, and audio calls. PeerJS wraps the browser's WebRTC implementation to provide a complete, configurable, and easy-to-use peer-to-peer connection API. Equipped with nothing but an ID, a peer can create a P2P data or media stream connection to a remote peer.

Also to broker connections, PeerJS connects to a PeerServer. Note that no peer-to-peer data goes through the server; The server acts only as a connection broker.

Arash Milani
  • 6,149
  • 2
  • 41
  • 47
1

If by peer to peer connection, you mean direct connection between the peers (i.e., not via a server) then yes it is probably possible in theory in most cases. But I have never seen someone who has implemented the solution.

You would need to implement a NAT hole punching system for TCP connections (they are not always 100% successful because of technical constraints which can't be solved at the software layer). Then, you'd just need to implement the websocket protocol on top of this tcp connection.

If by peer to peer connection, your are ok that communication passes via a central server (with a public address), then yes it is possible too. Both peers just need to connect to the central server, and it should just transfert the traffic between both peer.

Jérôme Verstrynge
  • 57,710
  • 92
  • 283
  • 453
  • `If by peer to peer connection, your are ok that communication passes ...` is that required only to initiate connection between both peers then they can communication without going to server ? or the whole trafic has to go through the server during the connection lifetime ? (if there will be a video streaming or file sharing the server connection will be overloaded..) – Mehdi Karamosly Oct 29 '13 at 23:00
  • 1
    You will need the server to establish first contact, then, in many cases, they can communicate directly. – Jérôme Verstrynge Oct 31 '13 at 08:22
  • do you have some documentation or tutorials of the process I really need to understand how it works, I need peers to communicate directly after first contact through the server. thx – Mehdi Karamosly Oct 31 '13 at 16:22