4

I wanted to know if it was possible to implement a Javascript only NAT punch through app. It should be able to run in the browser.

I am looking for a solution that would allow P2P connections with the punch through. A server would also be there, but only for making the introduction between the peers and exchanging IP addresses and ports.

If possible is it only UDP (have read that NAT punch through is much easier in UDP) or are TCP connections also possible?

2 Answers 2

1

You can. I packaged both a stun server and client for npm (https://npmjs.org/package/stunsrv). I haven't really documented the client-side of things but it is still there. Aside from that there are a few other client only packages available.

Edit: WebRTC might be something you would be interested in looking at also https://github.com/webRTC.

3
  • Hey, thanks for the answer. Is there any solution there for TCP that you know of?
    – kapad
    Commented Jul 21, 2013 at 21:20
  • Not sure, but it wouldn't be terrible to do a three way handshake programmatically if that is all you want out of TCP.
    – keyneom
    Commented Jul 21, 2013 at 22:02
  • Not just a three way handshake. I want to use this for file transfers. Not just voice or video, where UPD is fine and a small amount of packet loss is allowable. If TCP is very difficult then the option is to exchange a description file prior to starting the transfer.
    – kapad
    Commented Jul 22, 2013 at 7:53
1

TCP hole punching is possible but it depends on two factor one is OS based NAT and NAT hardware. Those 2 need to support as well. According to the following article UDP hole punching supports 82% and TCP hole punching only support 64%. You can find the technique in this article too.. All the best. http://www.brynosaurus.com/pub/net/p2pnat/

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.