0

我是 webRTC 的新手,想尝试一下。这是我下面的设置,所有这些都在本地主机上运行。我在 MacOS 上运行设置

chrome 浏览器 coturn 服务器上的 2 个 Web 客户端,在 localhost 上运行的信号机制,使用也在 localhost 上运行的 socket.io lib 在服务器上完成

我无法在 Web 客户端上获取远程音频和视频数据。

这就是我安装coturn的方式

brew install coturn

我没有做任何自定义配置。

这就是我运行 coturn 服务器的方式

turnserver --no-auth --verbose

这就是我运行 Web 服务器的方式

node index.js

这是在 Chrome 浏览器上执行的 javascript 中的 webRTC 配置

var pcConfig = { 'iceServers': [ { 'urls': 'turn:localhost:3478', 'credential': 'test', 'username': 'test' } ], iceTransportPolicy: "relay" };

这是我在 chrome://webrtc-internals/ URL 上看到的错误

icecandidateerror url: turn:localhost:3478?transport=tcp address: [0:0:0:x:x:x:x:x] port: 61077 host_candidate: [0:0:0:x:x:x:x:x]:61077 error_text: TURN allocate request timed out. error_code: 701

这是 coturn 输出日志

0: log file opened: /var/tmp/turn_21094_2020-05-02.log
0: WARNING: Cannot find config file: turnserver.conf. Default and command-line settings will be used.
0: WARNING: Cannot find config file: turnserver.conf. Default and command-line settings will be used.
0: 
RFC 3489/5389/5766/5780/6062/6156 STUN/TURN Server
Version Coturn-4.5.1.1 'dan Eider'
0: 
Max number of open files/sockets allowed for this process: 32767
0: 
Due to the open files/sockets limitation,
max supported number of TURN Sessions possible is: 16000 (approximately)
0: 

==== Show him the instruments, Practical Frost: ====

0: TLS supported
0: DTLS supported
0: DTLS 1.2 supported
0: TURN/STUN ALPN supported
0: Third-party authorization (oAuth) supported
0: GCM (AEAD) supported
0: OpenSSL compile-time version: OpenSSL 1.1.1d  10 Sep 2019 (0x1010104f)
0: 
0: SQLite supported, default database location is /usr/local/Cellar/coturn/4.5.1.1_1/var/db/turndb
0: Redis is not supported
0: PostgreSQL is not supported
0: MySQL is not supported
0: MongoDB is not supported
0: 
0: Default Net Engine version: 1 (UDP listening socket per session)

=====================================================

0: Domain name: 
0: Default realm: 
0: ERROR: 
CONFIG ERROR: Empty cli-password, and so telnet cli interface is disabled! Please set a non empty cli-password!
0: WARNING: cannot find certificate file: turn_server_cert.pem (1)
0: WARNING: cannot start TLS and DTLS listeners because certificate file is not set properly
0: WARNING: cannot find private key file: turn_server_pkey.pem (1)
0: WARNING: cannot start TLS and DTLS listeners because private key file is not set properly
0: NO EXPLICIT LISTENER ADDRESS(ES) ARE CONFIGURED
0: ===========Discovering listener addresses: =========
0: Listener address to use: 127.0.0.1
0: Listener address to use: ::1
0: Listener address to use: 192.168.0.10
0: Listener address to use: 2601:647:4001:73e0:83:ba63:ccbf:4787
0: Listener address to use: 2601:647:4001:73e0:983b:50cc:a7b8:c474
0: Listener address to use: 172.131.240.199
0: Listener address to use: 2001:4998:effd:7801::1041
0: =====================================================
0: Total: 5 'real' addresses discovered
0: =====================================================
0: NO EXPLICIT RELAY ADDRESS(ES) ARE CONFIGURED
0: ===========Discovering relay addresses: =============
0: Relay address to use: 192.168.0.10
0: Relay address to use: 172.131.240.199
0: Relay address to use: 2601:647:4001:73e0:83:ba63:ccbf:4787
0: Relay address to use: 2601:647:4001:73e0:983b:50cc:a7b8:c474
0: Relay address to use: 2001:4998:effd:7801::1041
0: =====================================================
0: Total: 5 relay addresses discovered
0: =====================================================
Cannot create pid file: /var/run/turnserver.pid: Permission denied
0: Cannot create pid file: /var/run/turnserver.pid
0: pid file created: /var/tmp/turnserver.pid
0: IO method (main listener thread): kqueue
0: IPv6: On this platform, I am using alternative behavior of TTL (HOPLIMIT) according to RFC 6156.
0: Wait for relay ports initialization...
0:   relay 192.168.0.10 initialization...
0:   relay 192.168.0.10 initialization done
0:   relay 172.131.240.199 initialization...
0:   relay 172.131.240.199 initialization done
0:   relay 2601:647:4001:73e0:83:ba63:ccbf:4787 initialization...
0:   relay 2601:647:4001:73e0:83:ba63:ccbf:4787 initialization done
0:   relay 2601:647:4001:73e0:983b:50cc:a7b8:c474 initialization...
0:   relay 2601:647:4001:73e0:983b:50cc:a7b8:c474 initialization done
0:   relay 2001:4998:effd:7801::1041 initialization...
0:   relay 2001:4998:effd:7801::1041 initialization done
0: Relay ports initialization done
0: IO method (general relay thread): kqueue
0: turn server id=0 created
0: IO method (general relay thread): kqueue
0: turn server id=1 created
0: IO method (general relay thread): kqueue
0: turn server id=2 created
0: IO method (general relay thread): kqueue
0: turn server id=3 created
0: IO method (general relay thread): kqueue
0: turn server id=4 created
0: IO method (general relay thread): kqueue
0: turn server id=5 created
0: IO method (general relay thread): kqueue
0: turn server id=6 created
0: IO method (general relay thread): kqueue
0: turn server id=7 created
0: IO method (general relay thread): kqueue
0: turn server id=8 created
0: IO method (general relay thread): kqueue
0: turn server id=9 created
0: IO method (general relay thread): kqueue
0: turn server id=10 created
0: IO method (general relay thread): kqueue
0: turn server id=11 created
0: IPv4. UDP listener opened on: 127.0.0.1:3478
0: IPv4. UDP listener opened on: 127.0.0.1:3479
0: IPv6. UDP listener opened on: ::1:3478
0: IPv6. UDP listener opened on: ::1:3479
0: IPv4. UDP listener opened on: 192.168.0.10:3478
0: IPv4. UDP listener opened on: 192.168.0.10:3479
0: IPv6. UDP listener opened on: 2601:647:4001:73e0:83:ba63:ccbf:4787:3478
0: IPv6. UDP listener opened on: 2601:647:4001:73e0:83:ba63:ccbf:4787:3479
0: IPv6. UDP listener opened on: 2601:647:4001:73e0:983b:50cc:a7b8:c474:3478
0: IPv6. UDP listener opened on: 2601:647:4001:73e0:983b:50cc:a7b8:c474:3479
0: IPv4. UDP listener opened on: 172.131.240.199:3478
0: IPv4. UDP listener opened on: 172.131.240.199:3479
0: IPv6. UDP listener opened on: 2001:4998:effd:7801::1041:3478
0: IPv6. UDP listener opened on: 2001:4998:effd:7801::1041:3479
socket: Protocol not supported
0: IPv4. TCP listener opened on : 127.0.0.1:3478
socket: Protocol not supported
0: IPv4. TCP listener opened on : 127.0.0.1:3479
socket: Protocol not supported
0: IPv6. TCP listener opened on : ::1:3478
socket: Protocol not supported
0: IPv6. TCP listener opened on : ::1:3479
socket: Protocol not supported
0: IPv4. TCP listener opened on : 192.168.0.10:3478
socket: Protocol not supported
0: IPv4. TCP listener opened on : 192.168.0.10:3479
socket: Protocol not supported
0: IPv6. TCP listener opened on : 2601:647:4001:73e0:83:ba63:ccbf:4787:3478
socket: Protocol not supported
0: IPv6. TCP listener opened on : 2601:647:4001:73e0:83:ba63:ccbf:4787:3479
socket: Protocol not supported
0: IPv6. TCP listener opened on : 2601:647:4001:73e0:983b:50cc:a7b8:c474:3478
socket: Protocol not supported
0: IPv6. TCP listener opened on : 2601:647:4001:73e0:983b:50cc:a7b8:c474:3479
socket: Protocol not supported
0: IPv4. TCP listener opened on : 172.131.240.199:3478
socket: Protocol not supported
0: IPv4. TCP listener opened on : 172.131.240.199:3479
socket: Protocol not supported
0: IPv6. TCP listener opened on : 2001:4998:effd:7801::1041:3478
socket: Protocol not supported
0: IPv6. TCP listener opened on : 2001:4998:effd:7801::1041:3479
0: Total General servers: 12
0: IO method (auth thread): kqueue
0: IO method (auth thread): kqueue
0: IO method (auth thread): kqueue
0: IO method (auth thread): kqueue
0: IO method (auth thread): kqueue
0: IO method (auth thread): kqueue
0: IO method (admin thread): kqueue
0: SQLite DB connection success: /usr/local/Cellar/coturn/4.5.1.1_1/var/db/turndb
6: IPv6. tcp or tls connected to: ::1:51182
6: IPv6. tcp or tls connected to: ::1:51183
6: IPv6. tcp or tls connected to: ::1:51184
6: IPv6. tcp or tls connected to: ::1:51185
6: IPv6. Local relay addr: ::1:58105
6: IPv6. Local relay addr: ::1:52192
6: IPv6. Local relay addr: ::1:59628
6: session 003000000000000001: new, realm=<>, username=<>, lifetime=600
6: session 003000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
6: IPv6. Local relay addr: ::1:53728
6: session 008000000000000001: new, realm=<>, username=<>, lifetime=600
6: session 002000000000000001: new, realm=<>, username=<>, lifetime=600
6: session 009000000000000001: new, realm=<>, username=<>, lifetime=600
6: session 008000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
6: session 002000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
6: session 009000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
6: IPv6. tcp or tls connected to: ::1:51186
6: IPv6. tcp or tls connected to: ::1:51187
6: IPv6. tcp or tls connected to: ::1:51188
6: IPv6. tcp or tls connected to: ::1:51189
6: IPv6. Local relay addr: ::1:58982
6: session 002000000000000002: new, realm=<>, username=<>, lifetime=600
6: session 002000000000000002: realm <> user <>: incoming packet ALLOCATE processed, success
6: IPv6. Local relay addr: ::1:50091
6: IPv6. Local relay addr: ::1:64548
6: IPv6. Local relay addr: ::1:59514
6: session 007000000000000001: new, realm=<>, username=<>, lifetime=600
6: session 007000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
6: session 004000000000000001: new, realm=<>, username=<>, lifetime=600
6: session 004000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
6: session 005000000000000001: new, realm=<>, username=<>, lifetime=600
6: session 005000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
6: session 003000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
6: session 008000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
6: session 009000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
6: session 002000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
6: session 004000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
6: session 007000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
6: session 002000000000000002: realm <> user <>: incoming packet ALLOCATE processed, success
6: session 005000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
6: session 003000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
6: session 009000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
6: session 008000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
6: session 002000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
6: session 007000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
6: session 005000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
6: session 004000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
6: session 002000000000000002: realm <> user <>: incoming packet ALLOCATE processed, success
7: session 002000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
7: session 003000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
7: session 008000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
7: session 009000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
7: session 002000000000000002: realm <> user <>: incoming packet ALLOCATE processed, success
7: session 004000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
7: session 007000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
7: session 005000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
9: session 008000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
9: session 002000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
9: session 003000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
9: session 009000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
9: session 002000000000000002: realm <> user <>: incoming packet ALLOCATE processed, success
9: session 007000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
9: session 004000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
9: session 005000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
13: session 003000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
13: session 009000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
13: session 008000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
13: session 002000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
13: session 002000000000000002: realm <> user <>: incoming packet ALLOCATE processed, success
13: session 007000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
13: session 004000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
13: session 005000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
21: session 003000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
21: session 008000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
21: session 009000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
21: session 002000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
21: session 004000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
21: session 002000000000000002: realm <> user <>: incoming packet ALLOCATE processed, success
21: session 007000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
21: session 005000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
29: session 002000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
29: session 003000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
29: session 008000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
29: session 009000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
29: session 002000000000000002: realm <> user <>: incoming packet ALLOCATE processed, success
29: session 007000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
29: session 005000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
29: session 004000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
37: session 002000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
37: session 003000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
37: session 008000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
37: session 009000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
37: session 002000000000000002: realm <> user <>: incoming packet ALLOCATE processed, success
37: session 007000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
37: session 004000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
37: session 005000000000000001: realm <> user <>: incoming packet ALLOCATE processed, success
50: session 003000000000000001: TCP socket closed remotely [::1]:51182
50: session 003000000000000001: usage: realm=<>, username=<>, rp=9, rb=252, sp=9, sb=972
50: session 003000000000000001: closed (2nd stage), user <> realm <> origin <>, local [::1]:3478, remote [::1]:51182, reason: TCP connection closed by client (callback)
50: session 002000000000000001: TCP socket closed remotely [::1]:51183
50: session 002000000000000001: usage: realm=<>, username=<>, rp=9, rb=252, sp=9, sb=972
50: session 003000000000000001: delete: realm=<>, username=<>
50: session 008000000000000001: TCP socket closed remotely [::1]:51184
50: session 008000000000000001: usage: realm=<>, username=<>, rp=9, rb=252, sp=9, sb=972
50: session 008000000000000001: closed (2nd stage), user <> realm <> origin <>, local [::1]:3478, remote [::1]:51184, reason: TCP connection closed by client (callback)
50: session 002000000000000001: closed (2nd stage), user <> realm <> origin <>, local [::1]:3478, remote [::1]:51183, reason: TCP connection closed by client (callback)
50: session 009000000000000001: TCP socket closed remotely [::1]:51185
50: session 009000000000000001: usage: realm=<>, username=<>, rp=9, rb=252, sp=9, sb=972
50: session 008000000000000001: delete: realm=<>, username=<>
50: session 002000000000000001: delete: realm=<>, username=<>
50: session 009000000000000001: closed (2nd stage), user <> realm <> origin <>, local [::1]:3478, remote [::1]:51185, reason: TCP connection closed by client (callback)
50: session 009000000000000001: delete: realm=<>, username=<>
50: session 002000000000000002: TCP socket closed remotely [::1]:51186
50: session 007000000000000001: TCP socket closed remotely [::1]:51187
50: session 002000000000000002: usage: realm=<>, username=<>, rp=9, rb=252, sp=9, sb=972
50: session 004000000000000001: TCP socket closed remotely [::1]:51188
50: session 002000000000000002: closed (2nd stage), user <> realm <> origin <>, local [::1]:3478, remote [::1]:51186, reason: TCP connection closed by client (callback)
50: session 004000000000000001: usage: realm=<>, username=<>, rp=9, rb=252, sp=9, sb=972
50: session 005000000000000001: TCP socket closed remotely [::1]:51189
50: session 007000000000000001: usage: realm=<>, username=<>, rp=9, rb=252, sp=9, sb=972
50: session 002000000000000002: delete: realm=<>, username=<>
50: session 004000000000000001: closed (2nd stage), user <> realm <> origin <>, local [::1]:3478, remote [::1]:51188, reason: TCP connection closed by client (callback)
50: session 005000000000000001: usage: realm=<>, username=<>, rp=9, rb=252, sp=9, sb=972
50: session 007000000000000001: closed (2nd stage), user <> realm <> origin <>, local [::1]:3478, remote [::1]:51187, reason: TCP connection closed by client (callback)
50: session 004000000000000001: delete: realm=<>, username=<>
50: session 005000000000000001: closed (2nd stage), user <> realm <> origin <>, local [::1]:3478, remote [::1]:51189, reason: TCP connection closed by client (callback)
50: session 007000000000000001: delete: realm=<>, username=<>
50: session 005000000000000001: delete: realm=<>, username=<> 

我的理解是 Chrome 浏览器正在等待 TURN 服务器响应,但超时并关闭连接。这个对吗?如果是这样,为什么 TURN 服务器没有响应?我是 webRTC 的新手,不知道我应该寻找什么。谁能帮助我在这里做错了什么或者我应该在哪里寻找问题?

注意:如果我删除iceTransportPolicy: "relay",我可以获得视频和音频流。只有当我强制中继时,流才会发送到对等连接。

4

0 回答 0