配置 CoTurn on Ubuntu 不工作

Configuration CoTurn on Ubuntu not working

在 MacBook 10.12.6 上使用 Trickle ICE 测试我的 STUN & TURN 服务器 (CoTurn) 时,我没有得到任何候选人 Chrome 62.0.3202.89:

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

与:

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

在 Digital Ocean 上,我创建了一个 droplet Ubuntu 16.04.3 x64 并安装了 CoTurn 4.5.0.3 版本:

sudo apt-get update
sudo apt-get install coturn

默认情况下,防火墙处于非活动状态。

接下来,我编辑了 sudo vi /etc/turnserver.conf 并提供了以下选项:

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

接下来,我编辑 sudo vi /etc/default/coturn 并取消注释选项:

TURNSERVER_ENABLED=1

然后我启动 Coturn 守护程序:

sudo systemctl start coturn
sudo systemctl status coturn

这给出了输出:

● 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.

请帮帮我,这里还需要什么才能让它工作?

启动失败:

sudo systemctl start coturn

这好像是 bug.

修复此错误:

sudo systemctl edit --full coturn

删除所有内容并粘贴:

[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

修改单元文件后,我重新加载 systemd 进程本身以获取我的更改:

sudo systemctl daemon-reload

现在开始实际工作:

sudo systemctl start coturn

让它在重启时自动重启:

sudo systemctl enable coturn

我遇到了同样的问题,但只需执行 systemctl restart coturn 即可让它开始为我工作。在此之前,只是执行 systemctl start 或 stop 报告成功但实际上没有启动任何进程。