From sgcWebSockets 4.5.2 version, TURN protocol is supported on Server and Client components. STUN Protocol was already supported on previous versions.
Traversal Using Relays around NAT (TURN) protocol enables a server to relay data packets between devices.
If the public IP address of both the caller and callee is not discovered, TURN provides a fallback technique to relay the call between endpoints.
Connecting a WebRTC session is an orchestrated effort done with the assistance of multiple WebRTC servers. The NAT traversal servers in WebRTC are in charge of making sure the media gets properly connected. These servers are STUN and TURN.
How WebRTC sessions connect
Directly
If both devices are on the local network, then there's no special effort needed to be done to get them connected to each other. If one device has the local IP address of the other device, then they can communicate with each other directly.
Directly with public IP Address
Connecting WebRTC directly using public IP address obtained via STUN protocol.
Route through a TURN Server
When peers are behind a NAT and there are Firewalls, direct connection is not possible, so a TURN server is required to route the data between the peers.
Components
- TsgcTURNClient: it's the client component that implements the TURN protocol and allows to Allocate, create permissions, Send Indications... to TURN Server.
- TsgcTURNServer: it's the server component that implements the TURN protocol.