【发布时间】:2020-12-27 02:39:03
【问题描述】:
我是 WebRTC 的新手,正在尝试创建我的第一个应用程序。我找到了这篇文章https://www.tutorialspoint.com/webrtc/webrtc_quick_guide.htm 并按照那里所说的做了。如果我在 Chrome 中对其进行测试,生成的应用程序可以正常工作。但是当我尝试在 2 个浏览器(Chrome 和 Mozilla)中测试这个应用程序时,它给了我这个错误:
未捕获(承诺中)DOMException:执行失败 “RTCPeerConnection”上的“setRemoteDescription”:会话错误代码: 错误内容。会话错误描述:数据通道类型不匹配。 预期 RTP,得到 SCTP..
当我从 Mozilla 客户端发送报价并且 Chrome 客户端尝试在这部分代码中对此报价给出答案时,就会发生这种情况:
myConnection.setRemoteDescription(new RTCSessionDescription(offer));
myConnection.createAnswer(function (answer) {
myConnection.setLocalDescription(answer);
send({
type: "answer",
answer: answer
});
}, function (error) {
alert("oops...error"); //<-- this alert fires all the time
});
我已经用谷歌搜索过这个,我发现的只是设置new RTCPeerConnection(configuration, { optional: [{RtpDataChannels: false}] }),但如果我这样做了,那么当我尝试发送一条消息时,它会说 dataChannel.readyState 没有打开。
我做错了什么?有任何帮助!
谢谢!
【问题讨论】: