未捕获的 DOMException:构造 'RTCPeerConnection' 失败:当 URL 方案为 "turn" 或 "turns" 时,用户名和凭据都需要

Uncaught DOMException: Failed to construct 'RTCPeerConnection': Both username and credential are required when the URL scheme is "turn" or "turns"

未捕获的 DOMException:构造失败 'RTCPeerConnection':当 URL 方案为“turn”或“turns”时,需要用户名和凭据。

我遇到错误。

我的代码和coturn配置是。

const iceConfiguration = {
        iceServers: [
            {
                username: 'myuser',
                credentials: 'userpassword',
                urls: [
                    'turn:public_ip_address:3478?transport=tcp',
                ]
            }
        ]
    }
    let peer = new RTCPeerConnection(iceConfiguration);
listening-port=3478

tls-listening-port=5349

listening-ip= turn:public_ip_address

external-ip= turn:public_ip_address

relay-ip= turn:public_ip_address

fingerprint

lt-cred-mech

user=myuser:userpassword

我试过写没有数组的 url[ ] 但结果相同。

我能做什么?

specification says 属性 是 credential,而不是 credentials。 您是否发现某个地方的拼写错误?

我认为错误是由“credential”拼写错误造成的

你能再试一次吗:

const iceConfiguration = {
        iceServers: [
            {
                username: 'myuser',
                credential: 'userpassword',
                urls: 'turn:public_ip_address:3478?transport=tcp'
            }
        ]
    }
    let peer = new RTCPeerConnection(iceConfiguration);

Coturn 可以通过 WebRTC samples Trickle ICE

进行测试

Here has some detailed TURN server test info

希望这些信息对您有所帮助。