Matrix Synapse TURN 配置失败

Matrix Synapse TURN 配置失败

平台:Debian 9

Matrix Synapse 版本:0.22.1-1

Coturn版本:4.5.0.5-1+b1

https://github.com/matrix-org/synapse/blob/master/docs/turn-howto.rst

我尝试按照本指南操作,但 TURN 服务器始终无法跨不同的 NAT 连接用户。以下是我采取的具体步骤:

$ sudo apt 安装 coturn

$ sudo nano /etc/turnserver.conf

编辑如下:

lt-cred-mech
use-auth-secret
static-auth-secret=[sharedsecretkey]
realm=turn.perthchat.org
no-tcp-relay
allowed-peer-ip=10.0.0.1
user-quota=16
total-quota=800

$ sudo nano /etc/default/coturn

#
# Uncomment it if you want to have the turnserver running as
# an automatic system service daemon
#
TURNSERVER_ENABLED=1

$ sudo ufw 允许 3478

$ sudo nano /etc/matrix-synapse/homeserver.yaml

turn_uris: [ "turn:turn.perthchat.org:3478?transport=udp", "turn:turn.perthchat.org:3478?transport=tcp" ]
turn_shared_secret: sharedsecretkey
turn_user_lifetime: 86400000
turn_allow_guests: True

$ sudo systemctl 启动 coturn

$ sudo systemctl 重新启动矩阵突触

跨 NAT 呼叫失败,卡在“呼叫连接...”状态

这些是在 coturn 神秘地停止生成新日志之前出现的最后日志:

$ tail -n 20 /var/log/turn.log
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 : 209.58.177.136:3478
0: IPv4. TCP listener opened on : 209.58.177.136: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: 209.58.177.136:3478
0: IPv4. UDP listener opened on: 209.58.177.136: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 (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: IO method (auth thread): epoll (with changelist)
0: SQLite DB connection success: /var/lib/turn/turndb

我尝试打开端口 3479,但没有任何反应,我不确定如何将 SSL 连接到 coturn 服务。

任何能使 TURN 呼叫正常运行的帮助都将不胜感激。

答案1

以下是我为解决此问题所采取的额外步骤:

首先我编辑 /etc/turnserver.conf 并取消注释:

# Lower and upper bounds of the UDP relay endpoints:
# (default values are 49152 and 65535)
#
min-port=49152
max-port=65535

然后我重置了服务:

$ sudo systemctl restart coturn
$ sudo systemctl restart matrix-synapse

然后我配置了一个简单的 A DNS 记录,将 turn.perthchat.org 指向服务器 IP。现在效果很好!:)

答案2

您是否查看过防火墙日志以查看数据包是否被拒绝?您使用的是哪种客户端/浏览器?如果是 chome,您能看到从 chrome://webrtc-internals 连接到 turn 的工作原理吗?

相关内容