Connecting two nodes, dynamic tcp connections tunneling through a central server

Conceptual system in my mind of what i'm looking for:

Given two hosts (can be pcs) !
Both can be on dynamic network (dynamic ip)!
Both connect to the same central server to find each other! (in my case need! One client host can act as a server too)
The server act as a bridge! And make the tunneling happen!
First host connect to the server! And the second too! Now the server map both nodes (hosts)!
And make forwarding (tunneling)!
Whenever host one send something to host 2 it will go to the central server! Through something like web socket! then the server send it to the second host! The second host answer back! Or whatever! The server handle the bridging and tunneling in the two ways!

Properties here:

  • nodes can connect dynamically! Without setting up networks or Dynamic dns ... Just like teamviewer or anydesk does!
  • tcp connections are tunneled and forwarded!
  • The two nodes connect and can work as if they were a one host!

To resume: pc1, pc2 => connect pc1 to pc2 without them having to know each other ip addresses! All dynamically! direct tunneling!

How to do that ?

After looking at different things! I just thought the easiet way is to implement something like that myself! as i can imgine how i can do it!

I needed that! While trying to run Android emulator on AWS EC2! And for forwarding adb to a remote emulator!

I'm not asking about solution for the android problem! But rather the system above! I'm wondering if there is already something that do what i described!

Otherwise it would take me some time!

For a solution that crossed my mind! I'm looking at a central websocket server! And tunneling tcp over ws!

What would be the name for such a system ?

And what are all the good possible ways to achieve that! How you would go about it ?

Some other ways then the system aboce that i looked up

For systems or problelms where you may think of the above! As like with the Android remote debugging!

One can think of:

Ssh reverse tunneling => require a static end! The server for example in my case! The server instance need to have ssh working! In AWS that require some work to setup a working agent! Not always straight forward!

Dynamic DNS => Port forwarding is needed! May be complicated to setup for some! Possible Security risks

Those for who may mention them! I'm only asking for the conceptual system mentioned above!

What i mentioned myself conceptually! Would be the most easy to go with thing and system! No complex setup to do! Just configure a one server! And all go smoothly and dynamically by design! Even for no advanced users! Like other developpers within the same team or organization! Just like teamviewer and anydesk and so many system already works!


Would something like openvpn as a solution to your problem be overkill? Openvpn does all you want but also encrypts network traffic. That encryption adds some complexity to the configuration.