6

I don't get any candidates while testing my STUN & TURN server (CoTurn) with Trickle ICE on a MacBook 10.12.6 using Chrome 62.0.3202.89:

https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/

with:

stun:<ip-adres>:3478
turn:<ip-adres>:3478 [username:test]    

On Digital Ocean I created a droplet Ubuntu 16.04.3 x64 and installed CoTurn version 4.5.0.3 doing:

sudo apt-get update
sudo apt-get install coturn

By default the firewall is inactive.

Next, I edited sudo vi /etc/turnserver.conf and give the following options:

fingerprint
lt-cred-mech
user=username:test
realm=<ip-adres>
listening-ip=<ip-adres>
relay-ip=<ip-adres>
external-ip=<ip-adres>

Next, I edit sudo vi /etc/default/coturn and uncomment the option:

TURNSERVER_ENABLED=1

Then I start the Coturn daemon:

sudo systemctl start coturn
sudo systemctl status coturn

This gives the output:

● coturn.service - LSB: coturn TURN Server
   Loaded: loaded (/etc/init.d/coturn; bad; vendor preset: enabled)
   Active: active (exited) since Sat 2017-11-11 20:27:10 UTC; 52s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1386 ExecStart=/etc/init.d/coturn start (code=exited, status=0/SUCCESS)
    Tasks: 0
   Memory: 0B
      CPU: 0

Nov 11 20:27:10 coturn systemd[1]: Starting LSB: coturn TURN Server...
Nov 11 20:27:10 coturn coturn[1386]:  * coturn disabled in /etc/default/coturn turnserver
Nov 11 20:27:10 coturn coturn[1386]:    ...done.
Nov 11 20:27:10 coturn coturn[1386]:  * See /etc/default/coturn for instructions on enabling turnserver
Nov 11 20:27:10 coturn coturn[1386]:    ...done.
Nov 11 20:27:10 coturn systemd[1]: Started LSB: coturn TURN Server.
Nov 11 20:27:53 coturn systemd[1]: Started LSB: coturn TURN Server.

Please help me, what is still needed here to let it work?

Herman Fransen
  • 2,200
  • 5
  • 24
  • 40
  • 1
    What browser and device are you trying the Trickle ICE from? Unless you hate life, do not use an iPhone or Safari while learning. – Justin Nov 09 '17 at 02:55
  • 1
    Also, the Ubuntu 16 package is an older version of CoTURN. Not sure if that is hurting you, but I had to build mine, which was somewhat of a pain. I was too stupid to write down the steps. Okay I remember now... I had to update it to the latest version to get the web admin interface to work. – Justin Nov 09 '17 at 02:59
  • 1
    @Justin, the resiprocate-turn-server from Ubuntu repositories works as it is. Maybe we should use it instead of CoTurn. – Velkan Nov 09 '17 at 07:05
  • @Justin I am using Chrome 62.0.3202.89 on a MacBook 10.12.6 when trying Trickle ICE (I updated the post too with this information) – Herman Fransen Nov 09 '17 at 09:17
  • @Justin, yes I know this is an older version, I don't mind for now. I first want to get it to work. I tried to build and install the latest version, that didn't work out since my linux knowledge is not sufficient. – Herman Fransen Nov 09 '17 at 09:35
  • @Justin I love my life, so for sure not using iPhone and/or Safari, but a good suggestion.... – Herman Fransen Nov 09 '17 at 09:36
  • @Velkan do you have a step by step manual for a newbie like me for the resiprocate-turn-server to make it work on Ubuntu? – Herman Fransen Nov 09 '17 at 09:45
  • Default config file (`/etc/reTurn/reTurnServer.config`) doesn't need changes. Have to add users to the user database file (`/etc/reTurn/users.txt`) by adding lines like: `::reTurn:AUTHORIZED`. The generation of the `` is explained in the `/etc/reTurn/reTurnServer.config` file: it's `echo -n myusername:reTurn:mypassword | md5sum`. – Velkan Nov 09 '17 at 10:04

2 Answers2

10

Starting doesn't work:

sudo systemctl start coturn

This seems like a bug.

To fix this bug:

sudo systemctl edit --full coturn

Delete everything and paste this:

[Unit]  
Description=coturn  
Documentation=man:coturn(1) man:turnadmin(1) man:turnserver(1)
After=syslog.target network.target

[Service]
Type=forking
User=turnserver
Group=turnserver
RuntimeDirectory=turnserver
RuntimeDirectoryMode=0750
EnvironmentFile=/etc/default/coturn
PIDFile=/run/turnserver/turnserver.pid
ExecStart=/usr/bin/turnserver --daemon --pidfile /run/turnserver/turnserver.pid --syslog -c /etc/turnserver.conf $EXTRA_OPTIONS
Restart=on-abort
LimitCORE=infinity
LimitNOFILE=1000000
LimitNPROC=60000
LimitRTPRIO=infinity
LimitRTTIME=7000000
CPUSchedulingPolicy=other
UMask=0007

[Install]
WantedBy=multi-user.target

After modifying the unit file, I reload the systemd process itself to pick up my changes:

sudo systemctl daemon-reload

Now starting actual works:

sudo systemctl start coturn

To make it automatically restart at reboot:

sudo systemctl enable coturn
Herman Fransen
  • 2,200
  • 5
  • 24
  • 40
  • 1
    Did you try the same command line steps on Ubuntu 16 version to confirm that it is indeed a version problem? The other one will accept the same commands. If it is for sure a version problem, do you want to mark this answer correct, or would you like me to create an answer about how to put the latest version on Ubuntu 16? – Justin Nov 09 '17 at 17:46
  • 2
    P.S. Firefox has a config setting to force using a relay server. Not sure about the others. That's what I use during testing so I don't have to change my application code, and it also lets me test the latency, etc. by doing A-B testing at the same time on different devices. – Justin Nov 09 '17 at 17:49
  • 1
    P.S.S. You left you IP address in the last code block. Might wanna change your CoTURN passwords. – Justin Nov 09 '17 at 17:50
  • @Justin I just did the test and I can confirm it is not a version problem. So I edited the solution. I will also change the ip address, although it was a test server which is not running anymore. I didn't know about the Firefox config setting, thanks for that and your other advise!! – Herman Fransen Nov 10 '17 at 17:57
  • @Justin I will dive more into it since after a reboot it's not working anymore. – Herman Fransen Nov 10 '17 at 18:03
  • 2
    After reading this, I looked again at my server and realized that I too made my own service file. Mine is not as pretty as yours, so I'll probably nab some of the lines from your example. I feel bad about this... I should have looked the other day. At least, if your luck is like mine, your server will be stable from here on out... That's why I forgot some of the details. I never have to touch it. – Justin Nov 12 '17 at 09:01
  • @Justin : Don't feel bad about this. I am happy with your help, and you did help me a lot. For me it's a learning proces, no worries. I write everything down, my whole server I can reproduce everything. That's very helpful for me. – Herman Fransen Nov 12 '17 at 09:14
  • @Justin : The other day I thought I would move to Ubuntu 17.10, but I realise now 16.04.3 is a LTS (Long-Term Support) so that's not smart to do. So I will need to install the latest version of CoTurn on this machine. if it does not work I will post a new question, and I hope you can help me again. – Herman Fransen Nov 12 '17 at 09:19
  • 1
    I will be offline for half a day or so, but, fortunately, I still have the steps in the terminal history. Let me know if you start a new SO question, and I'll write down the step by step. – Justin Nov 12 '17 at 10:20
  • @Justin : I tried and tried. Pfff not working. So I started a new question. [Click here](https://stackoverflow.com/questions/47249001/installing-coturn-4-5-0-6-on-ubuntu-16-04-3-x64-tls-not-working) to see it. Thanks a lot !!! – Herman Fransen Nov 12 '17 at 12:55
  • It doesn't work because .../default/coturn is missing, where can I take it? – Stepan Yakovenko Sep 20 '22 at 02:11
3

I had the same issue, but simply doing a systemctl restart coturn made it start working for me. Before that, just doing systemctl start or stop reported success but no process was actually started.

nfranzmeier
  • 111
  • 2