gpt4 book ai didi

webrtc - WebRTC:自Firefox v 53起,ICE失败

转载 作者:行者123 更新时间:2023-12-01 16:19:50 26 4
gpt4 key购买 nike

我的webRTC项目有问题。我的代码在Chrome和Firefox直到版本52之前都可以正常运行。自Firefox 53以来,我收到以下错误消息:“ICE失败,请参阅about:webrtc了解更多详细信息”。这是我的代码:

let connection;
let dataChannel;

const initCon = (initiatorBoolean, choosenONE) => {
createConnection();
startConnection(initiatorBoolean, choosenONE);
console.log('initCon(' + initiatorBoolean + ') / choosenONE = ' +choosenONE);
}
var boolJoin = false;
var lobbies = [];
var me = prompt("Please enter your name", "Bert");


// Helper für das Errorlogging
const logErrors = err => console.log(err);

// Websockets-Verbindung herstellen
const socket = io.connect('http://7daysclub.de:8080');

/* Methode to send information between to Users
*@param
*receiver= User who get the message
*type= Type of the message: could be init, joined, getUsers, setUsers, offer, answer, candidate
*descr= Content of the message
*/
const sendMessage = (receiver, type, descr) => {
message = Object.assign({to: 'default'}, {
user: receiver,
type: type,
descr: descr,
from: me
});
socket.emit('message', message);
console.log("send: " + message.type + ". to: " + message.user);
};

const createConnection = () => {
//Verbindung erstellen
connection = new RTCPeerConnection( {
'iceServers': [
{

/*
'urls': 'stun:stun.l.google.com:19302'
*/
'urls': 'stun:185.223.29.90:3478'


},
{

'urls': 'turn:185.223.29.90:3478',
'credential': '***',
'username': '***'


}
]
});
connection.oniceconnectionstatechange = function(event) {
console.log('state: '+connection.iceConnectionState );
if (connection.iceConnectionState === "failed" ||
connection.iceConnectionState === "disconnected" ||
connection.iceConnectionState === "closed") {
// Handle the failure
}
};

}

const call = choosenONE => {

if (!boolJoin) {
sendMessage(choosenONE, 'joined', null);
}

};

// Nachricht vom Signaling-Kanal empfangen
const receiveMessage = message => {
console.log("receive: " + message.type);

//Filter messages
if (message.user != 'all' && message.user != me) {
console.log("Block= " + message.user);
return;
}
// Nachricht verarbeiten
switch (message.type) {

// Partner ist verfügbar
case 'joined':
choosenONE = message.from;
sendMessage( choosenONE, 'init', null);
boolJoin = true;
initCon(true, choosenONE);
break;

case 'getUsers':
sendMessage(message.from,'setUsers', null)
lobbies.push(message.from);
lobbylist();
console.log('add User: ' + lobbies[lobbies.length-1] + ' to List');
break;

case 'setUsers':
lobbies.push(message.from);
console.log('add User: ' + lobbies[lobbies.length-1] + ' to List');
lobbylist();
break;

// Verbindungsaufbau wurde vom Partner angefordert
case 'init':
choosenONE = message.from;
boolJoin = true;
initCon(false, choosenONE);
break;


// Ein SDP-Verbindungsangebot ist eingegangen – wir erstellen eine Antwort
case 'offer':
connection
.setRemoteDescription(new RTCSessionDescription(message.descr))
.then(() => connection.createAnswer())
.then(answer => connection.setLocalDescription(new RTCSessionDescription(answer)))
.then(() => sendMessage(message.from,'answer', connection.localDescription, me))
.catch(logErrors);
break;

// Eine SDP-Verbindungsantwort auf unsere Anfrage ist eingegangen.
case 'answer':
connection.setRemoteDescription(new RTCSessionDescription(message.descr));
break;

// Der Partner hat eine mögliche Host-Port-Kombination ("ICE Candidate") gefunden
case 'candidate':
connection.addIceCandidate(new RTCIceCandidate({candidate: message.descr}));
break;
}
};

socket.on('message', receiveMessage);



// Verbindung initialisieren
const startConnection = (isCreator, choosenONE) => {
// Wenn wir mögliche Kommunikationsendpunkte finden, diese an den Partner weitergeben
connection.onicecandidate = event => {
if (event.candidate) {
sendMessage(choosenONE, 'candidate', event.candidate.candidate);
}
};

// Wenn die Gegenseite einen Stream hinzufügt, diesen an das video-element hängen
connection.ontrack = (e) => {
document.getElementById('vidRemote').src = window.URL.createObjectURL(e.stream);
};

// Falls wir der erste Teilnehmer sind, starten wir den Verbindungsaufbau
if (isCreator) {
// Datenkanal anlegen
dataChannel = connection.createDataChannel('chat');
onDataChannelCreated(dataChannel);

connection
.createOffer()
.then(offer => connection.setLocalDescription(new RTCSessionDescription(offer)))
.then(() => sendMessage(choosenONE, 'offer', connection.localDescription))
.catch(logErrors);

} else {

// Wenn wir nicht der Initiator sind, reagieren wir nur auf das Anlegen eines Datenkanals
connection.ondatachannel = function (event) {
dataChannel = event.channel;
onDataChannelCreated(dataChannel);
};

}
};



const onDataChannelCreated = (channel, choosenONE) => {
// Sobald der Datenkanal verfügbar ist, Chateingaben zulassen
channel.onopen = () => {
const enterChat = document.getElementById('enterChat');
enterChat.disabled = false;
enterChat.onkeyup = (keyevent) => {
// Bei "Enter" absenden
if (keyevent.keyCode === 13) {
dataChannel.send(enterChat.value);
appendChatMessage(me+':', enterChat.value);
enterChat.value = '';
}
}
};
channel.onmessage = (message) => appendChatMessage(choosenONE+':', message.data);
};

const appendChatMessage = (name, text) => {
const displayChat = document.getElementById('displayChat');
const time = new Date().toString('H:i:s');
displayChat.innerHTML = `<p>${name} - ${time}<br>${text}</p>` + displayChat.innerHTML;
};



function lobbylist() {
allusers = "";
lobbies.forEach( element => {
allusers += "<li><button onclick=\"call('"+element+"')\">"+element+"</button></li>"
});
document.getElementById('lobbylist').innerHTML = allusers;
}

//Alle User bei Ankunft erfragen
sendMessage('all','getUsers', null);
lobbylist();

并关于:webrtc =

(注册表/信息)成功插入“ice”(注册表):ice

(注册表/信息)成功插入'ice.pref'(注册表):ice.pref

(注册表/信息)成功插入“ice.pref.type”(注册表):ice.pref.type

(注册表/信息)成功插入'ice.pref.type.srv_rflx'(UCHAR):0x64

(注册表/信息)成功插入'ice.pref.type.peer_rflx'(UCHAR):0x6e

(注册表/信息)成功插入“ice.pref.type.host”(UCHAR):0x7e

(注册表/信息)成功插入'ice.pref.type.relayed'(UCHAR):0x05

(注册表/信息)成功插入'ice.pref.type.srv_rflx_tcp'(UCHAR):0x63

(注册表/信息)成功插入'ice.pref.type.peer_rflx_tcp'(UCHAR):0x6d

(注册表/信息)成功插入'ice.pref.type.host_tcp'(UCHAR):0x7d

(注册表/信息)插入'ice.pref.type.relayed_tcp'(UCHAR)成功:0x00

(注册表/信息)插入'stun'(注册表)成功:stun

(注册表/信息)插入'stun.client'(注册表)成功:stun.client

(注册表/信息)成功插入“stun.client.maximum_transmits”(UINT4):7

(注册表/信息)成功插入'ice.trickle_grace_period'(UINT4):5000

(注册表/信息)成功插入“ice.tcp”(注册表):ice.tcp

(注册表/信息)成功插入'ice.tcp.so_sock_count'(INT4):0

(注册表/信息)成功插入'ice.tcp.listen_backlog'(INT4):10

(注册表/信息)成功插入“ice.tcp.disable”(字符):\ 000

(通用/ EMERG)退出UDP套接字已连接

(通用/ ERR)UDP套接字错误:z处的内部错误:/build/build/src/dom/network/UDPSocketParent.cpp:283 this = 00000000120CC400

(ice / INFO)z:/build/build/src/media/mtransport/third_party/nICEr/src/net/nr_socket_multi_tcp.c:173函数nr_socket_multi_tcp_create_stun_server_socket跳过UDP STUN服务器(addr:IP4:185.223.29.90:3478 / UDP)

(ice / INFO)z:/build/build/src/media/mtransport/third_party/nICEr/src/net/nr_socket_multi_tcp.c:173函数nr_socket_multi_tcp_create_stun_server_socket跳过UDP STUN服务器(addr:IP4:185.223.29.90:3478 / UDP)

(ice / WARNING)z:/build/build/src/media/mtransport/third_party/nICEr/src/net/nr_socket_multi_tcp.c:617函数nr_socket_multi_tcp_listen失败,错误3

(ice / WARNING)ICE(PC:1512241952789000(id = 19327352835 url = http://7daysclub.de/webrtc2/)):无法创建被动TCP主机候选:3

(ice / NOTICE)ICE(PC:1512241952789000(id = 19327352835 url = http://7daysclub.de/webrtc2/)):对等(PC:1512241952789000(id = 19327352835 url = http://7daysclub.de/webrtc2/):default)没有带有非空检查列表的流

(ice / NOTICE)ICE(PC:1512241952789000(id = 19327352835 url = http://7daysclub.de/webrtc2/)):对等(PC:1512241952789000(id = 19327352835 url = http://7daysclub.de/webrtc2/):default)没有带有预应答请求的流

(ice / NOTICE)ICE(PC:1512241952789000(id = 19327352835 url = http://7daysclub.de/webrtc2/)):对等(PC:1512241952789000(id = 19327352835 url = http://7daysclub.de/webrtc2/):default)没有检查以启动

(ice / ERR)ICE(PC:1512241952789000(id = 19327352835 url = http://7daysclub.de/webrtc2/)):对等(PC:1512241952789000(id = 19327352835 url = http://7daysclub.de/webrtc2/):default)配对本地trick流ICE候选主机(IP4:192.168.0.4:54605 / UDP)

(ice / ERR)ICE(PC:1512241952789000(id = 19327352835 url = http://7daysclub.de/webrtc2/)):对等(PC:1512241952789000(id = 19327352835 url = http://7daysclub.de/webrtc2/):default)配对本地trick流ICE候选主机(IP4:192.168.0.4:62417 / TCP)活性

(眩晕/信息)无法识别的属性:0x802b

(stun / INFO)STUN-CLIENT(srflx(IP4:192.168.0.4:54605 / UDP | IP4:185.223.29.90:3478 / UDP)):收到响应;处理中

(ice / ERR)ICE(PC:1512241952789000(id = 19327352835 url = http://7daysclub.de/webrtc2/)):对等(PC:1512241952789000(id = 19327352835 url = http://7daysclub.de/webrtc2/):default)配对本地点滴ICE候选srflx(IP4:192.168.0.4:54605 / UDP | IP4:185.223.29.90:3478 / UDP)

(眩晕/信息)STUN-CLIENT(中继(IP4:192.168.0.4:54605 / UDP | IP4:185.223.29.90:3478 / UDP):: TURN):收到响应;处理中

(眩晕/警告)STUN-CLIENT(中继(IP4:192.168.0.4:54605 / UDP | IP4:185.223.29.90:3478 / UDP):: TURN):错误处理响应:可能重试,眩晕错误代码401。

(眩晕/信息)STUN-CLIENT(中继(IP4:192.168.0.4:54605 / UDP | IP4:185.223.29.90:3478 / UDP):: TURN):收到响应;处理中

(眩晕/警告)STUN-CLIENT(中继(IP4:192.168.0.4:54605 / UDP | IP4:185.223.29.90:3478 / UDP):: TURN):错误处理响应:可能重试,眩晕错误代码401。

(turn / WARNING)TURN(中继(IP4:192.168.0.4:54605 / UDP | IP4:185.223.29.90:3478 / UDP)):超过重试次数

(turn / WARNING)TURN(中继(IP4:192.168.0.4:54605 / UDP | IP4:185.223.29.90:3478 / UDP)):模式20,nr_turn_client_error_cb

(turn / WARNING)TURN(中继(IP4:192.168.0.4:54605 / UDP | IP4:185.223.29.90:3478 / UDP))失败

(turn / INFO)TURN(中继(IP4:192.168.0.4:54605 / UDP | IP4:185.223.29.90:3478 / UDP)):正在取消

(turn / WARNING)ICE-CANDIDATE(中继(IP4:192.168.0.4:54605 / UDP | IP4:185.223.29.90:3478 / UDP)):以状态4调用nr_turn_allocated_cb

(转/警告)ICE-CANDIDATE(中继(IP4:192.168.0.4:54605 / UDP | IP4:185.223.29.90:3478 / UDP)):nr_turn_allocated_cb失败

(ice / INFO)ICE(PC:1512241952789000(id = 19327352835 url = http://7daysclub.de/webrtc2/)):对等(PC:1512241952789000(id = 19327352835 url = http://7daysclub.de/webrtc2/):default)ckle流宽限期已过;将仅具有故障对的每个组件标记为故障。

(ice / INFO)ICE-PEER(PC:1512241952789000(id = 19327352835 url = http://7daysclub.de/webrtc2/):default)/STREAM(0-1512241952789000(id = 19327352835 url = http://7daysclub.de/webrtc2/)aLevel = 0)/ COMP(1):所有对均失败,并且宽限期已过。标记组件作为失败。

(ice / INFO)ICE-PEER(PC:1512241952789000(id = 19327352835 url = http://7daysclub.de/webrtc2/):default):所有检查完成成功= 0失败= 1

(通用/ EMERG)退出UDP套接字已连接

(通用/ ERR)UDP套接字错误:z处的内部错误:/build/build/src/dom/network/UDPSocketParent.cpp:283 this = 000000000BAE3000

(ice / INFO)z:/build/build/src/media/mtransport/third_party/nICEr/src/net/nr_socket_multi_tcp.c:173函数nr_socket_multi_tcp_create_stun_server_socket跳过UDP STUN服务器(addr:IP4:185.223.29.90:3478 / UDP)

(ice / INFO)z:/build/build/src/media/mtransport/third_party/nICEr/src/net/nr_socket_multi_tcp.c:173函数nr_socket_multi_tcp_create_stun_server_socket跳过UDP STUN服务器(addr:IP4:185.223.29.90:3478 / UDP)

(ice / WARNING)z:/build/build/src/media/mtransport/third_party/nICEr/src/net/nr_socket_multi_tcp.c:617函数nr_socket_multi_tcp_listen失败,错误3

(ice / WARNING)ICE(PC:1512242125375000(id = 19327352836 url = http://7daysclub.de/webrtc2/)):无法创建被动TCP主机候选:3

(ice / NOTICE)ICE(PC:1512242125375000(id = 19327352836 url = http://7daysclub.de/webrtc2/)):对等(PC:1512242125375000(id = 19327352836 url = http://7daysclub.de/webrtc2/):default)没有带有非空检查列表的流

(ice / NOTICE)ICE(PC:1512242125375000(id = 19327352836 url = http://7daysclub.de/webrtc2/)):对等(PC:1512242125375000(id = 19327352836 url = http://7daysclub.de/webrtc2/):default)没有带有预应答请求的流

(ice / NOTICE)ICE(PC:1512242125375000(id = 19327352836 url = http://7daysclub.de/webrtc2/)):对等(PC:1512242125375000(id = 19327352836 url = http://7daysclub.de/webrtc2/):default)没有检查以启动

(ice / ERR)ICE(PC:1512242125375000(id = 19327352836 url = http://7daysclub.de/webrtc2/)):对等(PC:1512242125375000(id = 19327352836 url = http://7daysclub.de/webrtc2/):default)配对本地trick流ICE候选主机(IP4:192.168.0.4:63286 / UDP)

(ice / ERR)ICE(PC:1512242125375000(id = 19327352836 url = http://7daysclub.de/webrtc2/)):对等(PC:1512242125375000(id = 19327352836 url = http://7daysclub.de/webrtc2/):default)配对本地trick流ICE候选主机(IP4:192.168.0.4:54433 / TCP)活性

(眩晕/信息)无法识别的属性:0x802b

(眩晕/信息)STUN-CLIENT(srflx(IP4:192.168.0.4:63286 / UDP | IP4:185.223.29.90:3478 / UDP)):收到响应;处理中

(ice / ERR)ICE(PC:1512242125375000(id = 19327352836 url = http://7daysclub.de/webrtc2/)):对等(PC:1512242125375000(id = 19327352836 url = http://7daysclub.de/webrtc2/):default)配对本地点滴ICE候选srflx(IP4:192.168.0.4:63286 / UDP | IP4:185.223.29.90:3478 / UDP)

(眩晕/信息)STUN-CLIENT(中继(IP4:192.168.0.4:63286 / UDP | IP4:185.223.29.90:3478 / UDP):: TURN):收到响应;处理中

(眩晕/警告)STUN-CLIENT(中继(IP4:192.168.0.4:63286 / UDP | IP4:185.223.29.90:3478 / UDP):: TURN):错误处理响应:可能重试,眩晕错误代码401。

(眩晕/信息)STUN-CLIENT(中继(IP4:192.168.0.4:63286 / UDP | IP4:185.223.29.90:3478 / UDP):: TURN):收到响应;处理中

(turn / INFO)TURN(中继(IP4:192.168.0.4:63286 / UDP | IP4:185.223.29.90:3478 / UDP)):成功分配的地址IP4:185.223.29.90:50497 / UDP寿命= 3600

(ice / ERR)ICE(PC:1512242125375000(id = 19327352836 url = http://7daysclub.de/webrtc2/)):对等(PC:1512242125375000(id = 19327352836 url = http://7daysclub.de/webrtc2/):default)配对本地点滴ICE候选继电器(IP4:192.168.0.4:63286 / UDP | IP4:185.223.29.90:50497 / UDP)

(ice / INFO)ICE(PC:1512242125375000(id = 19327352836 url = http://7daysclub.de/webrtc2/)):对等(PC:1512242125375000(id = 19327352836 url = http://7daysclub.de/webrtc2/):default)ckle流宽限期已过;将仅具有故障对的每个组件标记为故障。

(ice / INFO)ICE-PEER(PC:1512242125375000(id = 19327352836 url = http://7daysclub.de/webrtc2/):default)/STREAM(0-1512242125375000(id = 19327352836 url = http://7daysclub.de/webrtc2/)aLevel = 0)/ COMP(1):所有对均失败,并且宽限期已过。标记组件作为失败。

(ice / INFO)ICE-PEER(PC:1512242125375000(id = 19327352836 url = http://7daysclub.de/webrtc2/):default):所有检查完成成功= 0失败= 1

+++++++结束++++++++

我的turnserver配置如下所示:
# TURN listener port for UDP and TCP (Default: 3478).
# Note: actually, TLS & DTLS sessions can connect to the
# "plain" TCP & UDP port(s), too - if allowed by configuration.
#
listening-port=3478

# TURN listener port for TLS (Default: 5349).
# Note: actually, "plain" TCP & UDP sessions can connect to the TLS & DTLS
# port(s), too - if allowed by configuration. The TURN server
# "automatically" recognizes the type of traffic. Actually, two listening
# endpoints (the "plain" one and the "tls" one) are equivalent in terms of
# functionality; but we keep both endpoints to satisfy the RFC 5766 specs.
# For secure TCP connections, we currently support SSL version 3 and
# TLS version 1.0, 1.1 and 1.2. SSL2 "encapculation mode" is also supported.
# For secure UDP connections, we support DTLS version 1.
#
tls-listening-port=5349

# Listener IP address of relay server. Multiple listeners can be specified.
# If no IP(s) specified in the config file or in the command line options,
# then all IPv4 and IPv6 system IPs will be used for listening.
#
listening-ip=185.223.29.90

# Relay address (the local IP address that will be used to relay the
# packets to the peer).
# Multiple relay addresses may be used.
# The same IP(s) can be used as both listening IP(s) and relay IP(s).
#
# If no relay IP(s) specified, then the turnserver will apply the default
# policy: it will decide itself which relay addresses to be used, and it
# will always be using the client socket IP address as the relay IP address
# of the TURN session (if the requested relay address family is the same
# as the family of the client socket).
#
relay-ip=185.223.29.90


lt-cred-mech


# Realm for long-term credentials mechanism and for TURN REST API.
#
realm=7daysclub.de


#Local system IP address to be used for CLI server endpoint. Default value
# is 127.0.0.1.
#
cli-ip=185.223.29.90

# CLI server port. Default is 5766.
#
cli-port=5766

最佳答案

查看您的在线演示,远程SDP中没有候选人行,这表明该候选人从未添加。
sendMessage(choosenONE, 'candidate', event.candidate.candidate);
这将丢弃需要通过信号发送到远程对等方的sdpMid和sdpMLineIndex。将.catch添加到您的addIceCandidate以记录任何错误。

关于webrtc - WebRTC:自Firefox v 53起,ICE失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47612137/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com