WebRTC:CoTurn 无法中继流

WebRTC: CoTurn can't relay streams

我们在云 VM 上设置了 CoTurn。然后我们使用我们的 WebRTC 演示网站对其进行测试。我们发现它无法中继流,这意味着 WebRTC demo 的两端在不同子网时无法相互连接。

根据调查做了以下事情:

  1. 我们在 Ubuntu 20.04 上使用 CoTurn 4.5.1.1。 CoTurn 由 apt-get.
  2. 安装
  3. realm在turnserver.conf中设置,turnadmin创建的账号与realm绑定
  4. 入站 UDP 端口 1 ~ 65535 在云 VM 中打开。我们在VM中使用netcat监听udp:50000,在家里的PC上发送一些数据,可以接收到数据。
  5. WebRTC 演示网站在双方位于同一子网中时工作。

这是turnserver.conf:

listening-device=eth0
listening-port=3478
tls-listening-port=5349
listening-ip=172.16.9.209
relay-ip=172.16.9.209
external-ip=8.136.83.163
server-name=turn.locationbackbone.top
realm=turn.locationbackbone.top
log-file=/var/log/turn.log
cert=/etc/turn_server_cert.pem
pkey=/etc/turn_server_pkey.pem
fingerprint
lt-cred-mech
user=Jim:Jim
verbose

这是 WebRTC 演示的设置:

const peerConnection = new RTCPeerConnection({
    iceServers: [{
      urls: 'turn:turn.locationbackbone.top:3478',
      username: 'Jim',
      credential: 'Jim'
    }]
  });

这是来自 CoTurn 的日志:

18: handle_udp_packet: New UDP endpoint: local addr 172.16.9.209:3478, remote addr 58.39.2.24:22246
18: session 000000000000000001: realm <turn.locationbackbone.top> user <>: incoming packet BINDING processed, success
18: session 000000000000000001: realm <turn.locationbackbone.top> user <>: incoming packet message processed, error 401: Unauthorized
18: handle_udp_packet: New UDP endpoint: local addr 172.16.9.209:3478, remote addr 58.39.2.24:22247
18: session 000000000000000002: realm <turn.locationbackbone.top> user <>: incoming packet BINDING processed, success
18: session 000000000000000002: realm <turn.locationbackbone.top> user <>: incoming packet message processed, error 401: Unauthorized
18: IPv4. Local relay addr: 172.16.9.209:58189
18: session 000000000000000002: new, realm=<turn.locationbackbone.top>, username=<Jim>, lifetime=600
18: session 000000000000000002: realm <turn.locationbackbone.top> user <Jim>: incoming packet ALLOCATE processed, success
18: IPv4. Local relay addr: 172.16.9.209:53152
18: session 000000000000000001: new, realm=<turn.locationbackbone.top>, username=<Jim>, lifetime=600
18: session 000000000000000001: realm <turn.locationbackbone.top> user <Jim>: incoming packet ALLOCATE processed, success
19: session 000000000000000001: refreshed, realm=<turn.locationbackbone.top>, username=<Jim>, lifetime=0
19: session 000000000000000001: realm <turn.locationbackbone.top> user <Jim>: incoming packet REFRESH processed, success
19: handle_udp_packet: New UDP endpoint: local addr 172.16.9.209:3478, remote addr 182.139.173.74:49318
19: session 000000000000000003: realm <turn.locationbackbone.top> user <>: incoming packet BINDING processed, success
19: session 000000000000000003: realm <turn.locationbackbone.top> user <>: incoming packet message processed, error 401: Unauthorized
19: IPv4. Local relay addr: 172.16.9.209:64834
19: session 000000000000000003: new, realm=<turn.locationbackbone.top>, username=<Jim>, lifetime=600
19: session 000000000000000003: realm <turn.locationbackbone.top> user <Jim>: incoming packet ALLOCATE processed, success
19: session 000000000000000002: peer 182.139.173.74 lifetime updated: 300
19: session 000000000000000002: realm <turn.locationbackbone.top> user <Jim>: incoming packet CREATE_PERMISSION processed, success
19: session 000000000000000002: peer 172.16.9.209 lifetime updated: 300
19: session 000000000000000002: realm <turn.locationbackbone.top> user <Jim>: incoming packet CREATE_PERMISSION processed, success
20: session 000000000000000001: usage: realm=<turn.locationbackbone.top>, username=<Jim>, rp=4, rb=272, sp=4, sb=436
20: session 000000000000000001: closed (2nd stage), user <Jim> realm <turn.locationbackbone.top> origin <>, local 172.16.9.209:3478, remote 58.39.2.24:22246, reason: allocation timeout
20: session 000000000000000001: delete: realm=<turn.locationbackbone.top>, username=<Jim>

这是来自 chrome://webrtc-internals 的 'ICE candidate grid':

RTCIceCandidatePair_pNDACBB9_Rh5SDnOq   in-progress wifi        udp 0x27c1eff04fe3e00   0 / 0   31 / 0  0 / 0       11:21:10 AM
RTCIceCandidate_pNDACBB9    local-candidate 8.136.83.163    58189   relay(udp)  0x27c1eff                   
RTCIceCandidate_Rh5SDnOq    remote-candidate    8.136.83.163    64834   relay   0x27f1eff           

我们使用tshark抓取服务器的流量

58.39.2.24      172.16.9.209    25230   3478    STUN    Binding Request
58.39.2.24      172.16.9.209    25231   3478    STUN    Binding Request
172.16.9.209    58.39.2.24      3478    25230   STUN    Binding Success Response XOR-MAPPED-ADDRESS: 58.39.2.24:25230 MAPPED-ADDRESS: 58.39.2.24:25230 RESPONSE-ORIGIN: 8.136.83.163:3478
172.16.9.209    58.39.2.24      3478    25231   STUN    Binding Success Response XOR-MAPPED-ADDRESS: 58.39.2.24:25231 MAPPED-ADDRESS: 58.39.2.24:25231 RESPONSE-ORIGIN: 8.136.83.163:3478
58.39.2.24      172.16.9.209    25231   3478    STUN    Allocate Request UDP
172.16.9.209    58.39.2.24      3478    25231   STUN    Allocate Error Response error-code: 401 (Unauthorized) Unauthorized with nonce realm: turn.locationbackbone.top
58.39.2.24      172.16.9.209    25230   3478    STUN    Allocate Request UDP
172.16.9.209    58.39.2.24      3478    25230   STUN    Allocate Error Response error-code: 401 (Unauthorized) Unauthorized with nonce realm: turn.locationbackbone.top
58.39.2.24      172.16.9.209    25231   3478    STUN    Allocate Request UDP user: Jim realm: turn.locationbackbone.top with nonce
172.16.9.209    58.39.2.24      3478    25231   STUN    Allocate Success Response XOR-RELAYED-ADDRESS: 8.136.83.163:63533 XOR-MAPPED-ADDRESS: 58.39.2.24:25231 lifetime: 600
58.39.2.24      172.16.9.209    25230   3478    STUN    Allocate Request UDP user: Jim realm: turn.locationbackbone.top with nonce
172.16.9.209    58.39.2.24      3478    25230   STUN    Allocate Success Response XOR-RELAYED-ADDRESS: 8.136.83.163:55677 XOR-MAPPED-ADDRESS: 58.39.2.24:25230 lifetime: 600
222.211.167.109 172.16.9.209    55666   3478    STUN    Binding Request
172.16.9.209    222.211.167.109 3478    55666   STUN    Binding Success Response XOR-MAPPED-ADDRESS: 222.211.167.109:55666 MAPPED-ADDRESS: 222.211.167.109:55666 RESPONSE-ORIGIN: 8.136.83.163:3478
58.39.2.24      172.16.9.209    25231   3478    STUN    Refresh Request lifetime: 0 user: Jim realm: turn.locationbackbone.top with nonce
172.16.9.209    58.39.2.24      3478    25231   STUN    Refresh Success Response lifetime: 0
58.39.2.24      172.16.9.209    25230   3478    STUN    CreatePermission Request XOR-PEER-ADDRESS: 192.168.1.128:55666 user: Jim realm: turn.locationbackbone.top with nonce
172.16.9.209    58.39.2.24      3478    25230   STUN    CreatePermission Success Response
222.211.167.109 172.16.9.209    55666   3478    STUN    Allocate Request UDP
172.16.9.209    222.211.167.109 3478    55666   STUN    Allocate Error Response error-code: 401 (Unauthorized) Unauthorized with nonce realm: turn.locationbackbone.top
58.39.2.24      172.16.9.209    25230   3478    STUN    CreatePermission Request XOR-PEER-ADDRESS: 222.211.167.109:55666 user: Jim realm: turn.locationbackbone.top with nonce
172.16.9.209    58.39.2.24      3478    25230   STUN    CreatePermission Success Response
222.211.167.109 172.16.9.209    55666   3478    STUN    Allocate Request UDP user: Jim realm: turn.locationbackbone.top with nonce
172.16.9.209    222.211.167.109 3478    55666   STUN    Allocate Success Response XOR-RELAYED-ADDRESS: 8.136.83.163:64761 XOR-MAPPED-ADDRESS: 222.211.167.109:55666 lifetime: 600
58.39.2.24      172.16.9.209    25230   3478    STUN    CreatePermission Request XOR-PEER-ADDRESS: 8.136.83.163:64761 user: Jim realm: turn.locationbackbone.top with nonce
172.16.9.209    58.39.2.24      3478    25230   STUN    CreatePermission Success Response
58.39.2.24      172.16.9.209    25230   64761   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 192.168.1.128:55666
172.16.9.209    192.168.1.128   55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 222.211.167.109:55666
172.16.9.209    222.211.167.109 55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 8.136.83.163:64761
58.39.2.24      172.16.9.209    25230   64761   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 192.168.1.128:55666
172.16.9.209    192.168.1.128   55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 222.211.167.109:55666
172.16.9.209    222.211.167.109 55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 8.136.83.163:64761
58.39.2.24      172.16.9.209    25230   64761   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 192.168.1.128:55666
172.16.9.209    192.168.1.128   55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 222.211.167.109:55666
172.16.9.209    222.211.167.109 55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 8.136.83.163:64761
58.39.2.24      172.16.9.209    25230   64761   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 192.168.1.128:55666
172.16.9.209    192.168.1.128   55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 222.211.167.109:55666
172.16.9.209    222.211.167.109 55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 8.136.83.163:64761
58.39.2.24      172.16.9.209    25230   64761   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 192.168.1.128:55666
172.16.9.209    192.168.1.128   55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 222.211.167.109:55666
172.16.9.209    222.211.167.109 55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 8.136.83.163:64761
58.39.2.24      172.16.9.209    25230   64761   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 192.168.1.128:55666
172.16.9.209    192.168.1.128   55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 222.211.167.109:55666
172.16.9.209    222.211.167.109 55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 8.136.83.163:64761
58.39.2.24      172.16.9.209    25230   64761   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 192.168.1.128:55666
172.16.9.209    192.168.1.128   55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 222.211.167.109:55666
172.16.9.209    222.211.167.109 55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 8.136.83.163:64761
58.39.2.24      172.16.9.209    25230   64761   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 192.168.1.128:55666
172.16.9.209    192.168.1.128   55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 222.211.167.109:55666
172.16.9.209    222.211.167.109 55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 8.136.83.163:64761
58.39.2.24      172.16.9.209    25230   64761   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 192.168.1.128:55666
172.16.9.209    192.168.1.128   55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 222.211.167.109:55666
172.16.9.209    222.211.167.109 55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 8.136.83.163:64761
58.39.2.24      172.16.9.209    25230   64761   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 192.168.1.128:55666
172.16.9.209    192.168.1.128   55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 222.211.167.109:55666
172.16.9.209    222.211.167.109 55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 8.136.83.163:64761
58.39.2.24      172.16.9.209    25230   64761   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 192.168.1.128:55666
172.16.9.209    192.168.1.128   55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 222.211.167.109:55666
172.16.9.209    222.211.167.109 55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 8.136.83.163:64761
58.39.2.24      172.16.9.209    25230   64761   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 192.168.1.128:55666
172.16.9.209    192.168.1.128   55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 222.211.167.109:55666
172.16.9.209    222.211.167.109 55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 8.136.83.163:64761
58.39.2.24      172.16.9.209    25230   64761   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 192.168.1.128:55666
172.16.9.209    192.168.1.128   55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 222.211.167.109:55666
172.16.9.209    222.211.167.109 55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 8.136.83.163:64761
58.39.2.24      172.16.9.209    25230   64761   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 192.168.1.128:55666
172.16.9.209    192.168.1.128   55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 222.211.167.109:55666
172.16.9.209    222.211.167.109 55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 8.136.83.163:64761
58.39.2.24      172.16.9.209    25230   64761   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 192.168.1.128:55666
172.16.9.209    192.168.1.128   55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 222.211.167.109:55666
172.16.9.209    222.211.167.109 55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 8.136.83.163:64761
58.39.2.24      172.16.9.209    25230   64761   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 192.168.1.128:55666
172.16.9.209    192.168.1.128   55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 222.211.167.109:55666
172.16.9.209    222.211.167.109 55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 8.136.83.163:64761
58.39.2.24      172.16.9.209    25230   64761   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 192.168.1.128:55666
172.16.9.209    192.168.1.128   55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 222.211.167.109:55666
172.16.9.209    222.211.167.109 55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 8.136.83.163:64761
58.39.2.24      172.16.9.209    25230   64761   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 192.168.1.128:55666
172.16.9.209    192.168.1.128   55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 222.211.167.109:55666
172.16.9.209    222.211.167.109 55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 8.136.83.163:64761
58.39.2.24      172.16.9.209    25230   64761   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 192.168.1.128:55666
172.16.9.209    192.168.1.128   55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 222.211.167.109:55666
172.16.9.209    222.211.167.109 55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 8.136.83.163:64761
58.39.2.24      172.16.9.209    25230   64761   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 192.168.1.128:55666
172.16.9.209    192.168.1.128   55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 222.211.167.109:55666
172.16.9.209    222.211.167.109 55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 8.136.83.163:64761
58.39.2.24      172.16.9.209    25230   3478    STUN    Binding Request
172.16.9.209    58.39.2.24      3478    25230   STUN    Binding Success Response XOR-MAPPED-ADDRESS: 58.39.2.24:25230 MAPPED-ADDRESS: 58.39.2.24:25230 RESPONSE-ORIGIN: 8.136.83.163:3478
58.39.2.24      172.16.9.209    25230   64761   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 192.168.1.128:55666
172.16.9.209    192.168.1.128   55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 222.211.167.109:55666
172.16.9.209    222.211.167.109 55677   55666   STUN    Binding Request user: l3iy:poWX
58.39.2.24      172.16.9.209    25230   3478    STUN    Send Indication XOR-PEER-ADDRESS: 8.136.83.163:64761
58.39.2.24      172.16.9.209    25230   3478    STUN    Refresh Request lifetime: 0 user: Jim realm: turn.locationbackbone.top with nonce
172.16.9.209    58.39.2.24      3478    25230   STUN    Refresh Success Response lifetime: 0
222.211.167.109 172.16.9.209    55666   3478    STUN    Refresh Request lifetime: 0 user: Jim realm: turn.locationbackbone.top with nonce
172.16.9.209    222.211.167.109 3478    55666   STUN    Refresh Success Response lifetime: 0

我们注意到被叫方只能收到以下消息:coturn:3478 -> callee STUN,因为端口 3478 是被叫方曾经发送过数据包的唯一端口。 coturn服务器其他端口发送的数据包丢失。我们怀疑NAT是一种端口受限的锥形甚至是对称的。

我们如何启用中继?

有 2 个客户端(A 来自 58.39.2.24:25230,B 来自 222.211.167.109:55666)。两者都成功获得分配(分别为 8.136.83.163:556778.136.83.163:64761)。

客户端A然后创建3个权限,一个给192.168.1.128:55666(私有,可能无法使用),一个给222.211.167.109:55666(直接),一个给8.136.83.163:64761(中继))。

然后客户端A开始向3个目标发送STUN绑定请求。注定要222.211.167.109:55666的人永远得不到答案,所以一定是coturn无法到达。

客户端 B 应该为 8.136.83.163:55677 创建权限,这样 coturn 将允许传送来自 A 的 STUN 绑定请求,实现 relay-to-relay 连接:A <--> coturn <- -> coturn <--> B.