Coturn WebRTC issue on AZURE VM (Ubuntu Server 16.04 LTS)

后端 未结 1 1730
一生所求
一生所求 2021-01-27 17:05

I use webRTC to establish a web browser real-time communication with other browsers. To make sure this connection is always solid I want to set up my own STUN/TURN Server. I dec

相关标签:
1条回答
  • 2021-01-27 17:42

    I suspect some of your configuration is not set right on your CoTurn server. I will give you my configuration that works for me. I also use Ubuntu Server 16.04 LTS (Digital Ocean). Delete your CoTurn server first (better take a fresh droplet), and reinstall it:

    sudo apt-get update
    sudo apt-get install coturn
    

    Next, edit sudo vi /etc/turnserver.conf and change it to the following options (delete all other settings):

    fingerprint
    lt-cred-mech
    realm=ip-of-your-server-accessible-from-outside
    listening-ip=ip-of-your-server-accessible-from-outside
    user=test:test
    

    Next, edit sudo vi /etc/default/coturn and change it to the following options (delete all other settings):

    TURNSERVER_ENABLED=1
    

    Your firewall on Ubuntu may prevent incoming connections. Configure your server to allow incoming STUN / TURN connections on port 3478. In case you use UFW, the command is:

    sudo ufw allow 3478
    

    Reboot your Ubuntu server. After rebooting make sure your turnserver is running:

    turnserver -o
    

    After another reboot of your Ubuntu the turnserver is not running anymore. To get over this you may want the turnserver to be a system service.

    In your app you need to add something like:

    peerConnectionConfig = {
        'iceServers': [
          { 'urls': 'stun:ip-of-your-server:3478' },
          { 'urls': 'turn:ip-of-your-server:3478', 'username': 'test', 'credential': 'test' }
        ]
      };
    peerConnection = new RTCPeerConnection(peerConnectionConfig);
    

    Run your WebRTC app in Firefox in two tabs where they make the connection within the same LAN. Because your app will now not use STUN or TURN we can be sure the app is not the problem

    Now do the same test but force Firefox to use the TURN server or replay. Open a new tab and type about:config. Search for media.peerconnection.ice.relay_only and set it to true. At this moment Firefox only uses TURN relay. If your WebRTC app works now, you can be sure your TURN server is working great.

    0 讨论(0)
提交回复
热议问题