STUN and TURN Servers
In order for the Signaling and Web Server to be able to negotiate a direct connection between the WebRTC Proxy Server and the browser, each party needs to send the other its own IP address. The browser needs to be able to access the IP address sent by the WebRTC Proxy Server, and vice-versa.
Within a simple local area network, each endpoint can usually assume that the other party can access it using the private IP address known to its own network card. Over the open Internet, across subnets, or when network address translation (NAT) services intervene between the browser and the WebRTC Proxy Server, this is not usually the case. Instead, each party needs to find out its own publicly visible IP address by querying a server that implements the STUN (Session Traversal Utilities for NAT) protocol. After the STUN server tells each endpoint its publicly visible IP address, the Signaling and Web Server can continue brokering their direct connection.
Alternatively, you can use a TURN server to relay the media stream between the WebRTC Proxy Server and the browser. With the TURN protocol, the TURN server connects to the WebRTC Proxy Server on one hand, and connects to the browser on the other hand. The WebRTC Proxy Server sends all of its streamed data to the TURN server, which forwards the data on to the browser. In this case, there is no direct connection between the WebRTC Proxy Server and the browser. (If you need to support mobile devices over wireless carrier networks, you may have no choice but to use a TURN server. Mobile networks often prevent clients from successfully connecting via the WebRTC protocol.)
The STUN and TURN protocols together, along with the ability to fall back from one server to another, make up the ICE (Interactive Connectivity Establishment) framework.
You can find several open-source implementations of STUN and TURN servers on the Internet. There are even public STUN servers that you can use for free instead of hosting your own, although you should exercise caution when using a service that you are not hosting yourself. (Because of the throughput and bandwidth involved in relaying media through the TURN protocol, public TURN services are rarely available for free.)
For convenience, the Unreal Engine also ships with binary versions of the STUN and TURN reference servers that are defined in the C++ WebRTC SDK. You can find these in the
Engine/Source/ThirdParty/WebRTC/rev.23789/programs/Win64/VS2017/release folder under your Unreal Engine install location. These implementations may not offer production-grade reliability, but they may help you get started.
To set up Pixel Streaming to use ICE connections, you need to set the host names of the STUN and TURN servers you want to use in the peerConnectionOptions configuration parameter for the Signaling and Web Server. For details on how to format this parameter, and how to supply it, see the Pixel Streaming Reference.
In addition, if you're hosting your own STUN or TURN server, you must make sure that the IP address and port you specify for it in the peerConnectionOptions parameter are visible on the open Internet.