turnserver.md 3.5 KB

Setting for TURN Servers

If streaming is not functioning correctly in Unity Render Streaming, consult the troubleshooting guide. If you are experiencing firewall issues, you may need to change your firewall settings or use a TURN server.

TURN(Traversal Using Relay around NAT) is a communication protocol for transmitting across NAT and firewalls. A TURN server must be set up on the outside of the NAT in order to use TURN.

This document covers the process of linking Unity Render Streaming to a TURN server.

Instance settings

coturn software is an open source implementation for TURN servers. The following is an explanation for running coturn on a GCP instance.

ubuntu-minimal-1604-xenial-v20190628 is used in the instance image so that the apt command can be used to install coturn. If the distribution is supported by coturn, there shouldn't be any issues. See the coturn documentation for details on coturn.

Firewall rules settings

The port used by the TURN server needs to be public, so add the following settings to the firewall.

Protocol PORT
TCP 32355-65535, 3478-3479
UDP 32355-65535, 3478-3479

TURN firewall rules

Installing coturn

Log into the GCP instance with ssh. Install coturn.

sudo apt install coturn

Change the settings for booting with a daemon to use coturn as a TURN server. Edit the following file.

sudo vim /etc/default/coturn

Add the following line.

TURNSERVER_ENABLED=1

Next, edit the coturn settings file.

sudo vim /etc/turnserver.conf

Remove the comments from the following lines, and add any necessary information.

# The TURN server IP address to be sent to external peers
external-ip=10.140.0.4

# Validate credentials
lt-cred-mech

# Designate username and password
user=username:password

# Realm settings
realm=yourcompany.com

# Log file settings
log-file=/var/tmp/turn.log

When finished, restart the coturn service.

sudo systemctl restart coturn

Connection verification

After completing the coturn settings, check the log to verify that the TURN server is function correctly.

tail -f /var/tmp/turn_xxxx-xx-xx.log

Use the webrtc sample to connect to the TURN server. Use the following settings and click Add Server.

Parameter Example
STUN or TURN URI turn:xx.xx.xx.xx:3478?transport=tcp
TURN username username
TURN password password

TURN connection testing

Click Gather candidates to show a list of potential communication paths. Verify that a log is also printed on the TURN server side.

Browser side changes

Change the config.iceServers settings under video-player.js on the browser side.

config.iceServers = [{
  	urls: ['stun:stun.l.google.com:19302']
	}, {
    urls: ['turn:xx.xx.xx.xx:3478?transport=tcp'], 
   	username: 'username', 
   	credential: 'password'
  }
];

Unity side changes

Add the TURN server settings to Ice Server in the Render Streaming inspector.

TURN Render Streaming inspector