我想了解是什么在不使用 STUN 服务器的本地 webRTC 应用程序中生成 ICE 候选对象。
我有一个基本的 webRTC 应用程序,支持两个对等点之间的视频/音频通信和文件共享,当我在 Mozilla Firefox 上打开它时,该应用程序按预期运行,但当我在 Google Chrome 上运行它时,onicecandidate返回null
我的 RTCPeerConnection
myConnection = new RTCPeerConnection();
Run Code Online (Sandbox Code Playgroud)
设置对等连接
myConnection.createOffer().then(offer => {
currentoffer = offer
myConnection.setLocalDescription(offer);
})
.then(function () {
myConnection.onicecandidate = function (event) {
console.log(event.candidate);
if (event.candidate) {
send({
type: "candidate",
candidate: event.candidate
});
}
};
send({
type: "offer",
offer: currentoffer
});
})
.catch(function (reason) {
alert("Problem with creating offer. " + reason);
});
Run Code Online (Sandbox Code Playgroud)
在 Mozilla Firefox 上,您可以在控制台中看到在每个“onicecandidate”事件中收集的所有 ICE 候选者日志

在 Chrome 上,输出为 null
