# Setup ICE Server

The ICE server helps the client connect to the render server.
This is done by setting up a TURN/STUN server for address and port resolution, as well as proxying for the WebRTC protocol.

## Requirements

- Ensure that ports `3478 TCP/UDP` are open to clients and render servers.
  - It is possible to use different ports.
- Ensure that ports `50000-51000 UDP` are open to clients and render servers.
  - It is possible to use different port ranges.
- A **Windows** host is required for the standalone CAXturn installation.
- On **Linux**, CAXturn is available as a Docker image (`quay.io/caxperts/caxturn`). See the Linux setup guide for a sample `docker-compose.yml`.

## Setup

During installation, CAXturn is provided together with a sample configuration file.

### Configuration

```json
{
    "publicIp": "1.1.1.1",
    "username": "1234",
    "password": "5678",
    "realm": "caxnet",
    "minPort": 50000,
    "maxPort": 51000,

    "enableTCP": true,
    "tcpPort": 3478,

    "enableUDP": true,
    "udpPort": 3478
}
```
| Key         | Description                                                                 |
|-------------|-----------------------------------------------------------------------------|
| `publicIp`  | The public IP address of the server or service. |
| `username`  | The user name used for authentication. |
| `password`  | The password used for authentication. |
| `realm`     | The authentication realm, typically representing a domain or service name. The value itself is not important, but it must be specified. |
| `minPort`   | The minimum port number for dynamic UDP port allocation. |
| `maxPort`   | The maximum port number for dynamic UDP port allocation. |
| `enableTCP` | Enables the TCP protocol for initial communication when set to `true`. |
| `tcpPort`   | The port number used for initial TCP communication. |
| `enableUDP` | Enables the UDP protocol for initial communication when set to `true`. |
| `udpPort`   | The port number used for initial UDP communication. |

### Running

By default, running `CAXturn.exe` is sufficient, as it already searches for a `config.json` file. A manual file can be specified by using `-config`.

It is recommended to set up a scheduled task to run CAXturn after a reboot.

### Turn URLs

To use the ICE server in Portal, the URLs must be specified in the following format:

`turn:<hostname/ip/subdomain>:<udp-port>`

`turn:<hostname/ip/subdomain>:<tcp-port>?transport=tcp`

## Alternatives

There are alternatives to CAXturn. It is possible to use cloud TURN hosting providers or tools such as `coturn`.
