ubuntu 中的 Coturn 设置

Wil*_*Lee 2 ubuntu google-cloud-platform coturn

我正在尝试在 Google Cloud Ubuntu 实例中运行 Coturn。

在新的 VM 中安装 coturn 使用:sudo apt install coturn

我用私钥创建了一个证书文件并更新/etc/turnserver.conf:

listening-port=3478
tls-listening-port=5349
listening-ip=10.128.0.2
relay-ip=10.128.0.2
external-ip=35.192.224.52/10.128.0.2
lt-cred-mech
userdb=/var/lib/turn/turndb
user=attitudemarketing:password
cert=cert.crt
pkey=private.key
no-stdout-log
Run Code Online (Sandbox Code Playgroud)

一切似乎都在运行,但是当我尝试 Trickle Ice 时:https : //webrtc.github.io/samples/src/content/peerconnection/trickle-ice/它似乎不起作用

这是来自 coturn 的日志文件:

0: log file opened: /var/log/turn_1978_2017-10-12.log
0: pid file created: /var/run/turnserver.pid
0: IO method (main listener thread): epoll (with changelist)
0: Wait for relay ports initialization...
0:   relay 10.128.0.2 initialization...
0:   relay 10.128.0.2 initialization done
0:   relay ::1 initialization...
0:   relay ::1 initialization done
0: Relay ports initialization done
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=1 created
0: IPv4. TCP listener opened on : 127.0.0.1:3478
0: IPv4. TCP listener opened on : 127.0.0.1:3479
0: IPv4. TCP listener opened on : 10.128.0.2:3478
0: IPv4. TCP listener opened on : 10.128.0.2:3479
0: IPv6. TCP listener opened on : ::1:3478
0: IPv6. TCP listener opened on : ::1:3479
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=0 created
0: IPv4. TCP listener opened on : 127.0.0.1:3478
0: IPv4. TCP listener opened on : 127.0.0.1:3479
0: IPv4. TCP listener opened on : 10.128.0.2:3478
0: IPv4. TCP listener opened on : 10.128.0.2:3479
0: IPv6. TCP listener opened on : ::1:3478
0: IPv6. TCP listener opened on : ::1:3479
0: IPv4. UDP listener opened on: 127.0.0.1:3478
0: IPv4. UDP listener opened on: 127.0.0.1:3479
0: IPv4. UDP listener opened on: 10.128.0.2:3478
0: IPv4. UDP listener opened on: 10.128.0.2:3479
0: IPv6. UDP listener opened on: ::1:3478
0: IPv6. UDP listener opened on: ::1:3479
0: Total General servers: 2
0: IO method (auth thread): epoll (with changelist)
0: IO method (admin thread): epoll (with changelist)
0: IPv4. CLI listener opened on : 127.0.0.1:5766
0: IO method (auth thread): epoll (with changelist)
0: SQLite DB connection success: /var/lib/turn/turndb
Run Code Online (Sandbox Code Playgroud)

我不确定它是否正常工作,或者是否因为它位于 Google 云 VM 内而被阻止。

mar*_*o56 5

我最近在 AWS Ubuntu EC2 实例上设置了 coturn 服务器。Google Cloud 实例的流程应该相同。

首先,确保打开以下入站端口(TCP&UDP):

  • 3478 和 3479(标准监听端口和替代监听端口)
  • 5349 和 5350(标准 tls-listening-port 和替代 tls-listening-port)
  • 49152 - 65535(标准中继端口)

出于测试目的,在您的服务器可访问之前,将以下内容添加到 turnserver.conf:

no-tls
no-dtls
verbose
Run Code Online (Sandbox Code Playgroud)

通常,您还需要添加fingerprint到您的配置中。

有关这些的说明,请检查。我现在也会从你的配置中删除cert=cert.crtpkey=private.key

此时,您应该能够从远程计算机访问您的服务器。测试此问题的最佳方法通常是访问远程计算机上的浏览器,然后转到“your-public-ip”:3478。

如果服务器可访问,您应该在浏览器中看到以下内容:

图片

如果没有,请尝试以下操作:

  • 从 turnserver.conf 中删除监听 ip、中继 ip、外部 ip 和监听端口,让 coturn 自行决定(这对我在 AWS EC2 上有效)

  • 将侦听端口设置为 80,将 alt-listening-port 设置为 443,然后打开服务器上的端口。这将有助于抵御非常严格的防火墙,但我认为这不应该是 Google VM 上的问题。