Linux

Matrix Synapse TURN 配置失敗

  • January 24, 2020

平台:Debian 9

矩陣突觸版本: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 install 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 start 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 呼叫工作將不勝感激。

以下是我為解決此問題而採取的額外步驟:

首先我編輯 /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。現在效果很好!:)

您是否查看過防火牆日誌以查看數據包是否被拒絕?您使用的是哪個客戶端/瀏覽器?如果是 chome,你能從 chrome://webrtc-internals 看到連接到 turn 的工作原理嗎?

引用自:https://serverfault.com/questions/871674