How to use TURN Server in Ant Media Server?

Viewed 1482

We have issues with using Ant Media server due to firewall restrictions with many customers. If I use the TURN server, Can I solve this problem (for publish/play)? We are using the Conference Room type in our code.

Thanks.

1 Answers

You can enable TURN server for publishing and playing pages. For instance on your publishing page(/usr/local/antmedia/webapps/WebRTCAppEE/index.html), there is pc_config JavaScript variable like this

    var pc_config = {
            'iceServers' : [ {
                'urls' : 'stun:stun.l.google.com:19302'
            } ]
        };

You can just change its value according to your TURN configuration like below

    var pc_config = {
       iceServers: [
                    { urls: "turn:{TURN_SERVER_URL}",
                      username: "{TURN_SERVER_USERNAME}",
                      credential: "{TURN_SERVER_PASS}",
                    }
                   ]
    };

UPDATE

Ant Media Server v2.4.4 and later version will support adding TURN server for the server side. In order to do that, follow the instructions.

  1. Edit your application's configuration file(`/usr/local/antmedia/webapps/{YOUR_APP_FOLDER}/WEB-INF/red5-web.properties) with your favorite text editor(vi, nano, etc.)
  2. Add the following properties
    settings.webrtc.stunServerURI=turn:WRITE_YOUR_TURN_SERVER_URL
    settings.webrtc.turnServerUsername=WRITE_YOUR_TURN_SERVER_USERNAME
    settings.webrtc.turnServerCredential=WRITE_YOUR_TURN_SERVER_PASSWORD
    
  3. Save the file and restart the Ant Media Server
    sudo service antmedia restart
    

You can set custom stun server to the following property settings.webrtc.stunServerURI. Just don't forget to start with stun: prefix. If you don't have username or password, you can leave the fields blank.

Related