How do you get around NATs using WebRTC without a TURN server?

后端 未结 2 1815
南方客
南方客 2021-01-07 13:39

I\'m trying to make a peer to peer Javascript game that can be played on mobile browsers.

  • I have been able to successfully set up a p2p connection between two
2条回答
  •  醉话见心
    2021-01-07 14:11

    There are a few different factors that could at at play here.

    • NAT Types on both sides
    • IP Family (IPv4 or IPv6)
    • Protocols (Is UDP Allowed at all?)

    I would determine what NAT type you are behind on each side, you can read more about that here https://webrtchacks.com/symmetric-nat. If both networks are behind symmetric NATs you are going to need a TURN server.

    If you don't have a browser you could also use Pion TURN a Go TURN client and server.

    I would also check when gathering candidates if there is an intersection on IPv4/IPv6. Some phone providers are only giving out IPv6.

    UDP may not be allowed at all. This isn't common, but possible. In this case you will be forced to use TURN. NAT traversal via TCP is possible, but not supported by WebRTC AFAIK.

提交回复
热议问题