解决WebRTC报错:DOMException: Error processing ICE candidate
问题原因:
So there, you can't add ICE candidates without setting remote description......
原作者的大意是说如果在没有设置远程SDP的情况下,是不能调用PeerConnection.addIceCandidate()方法的。
解决方案:
来自于: https://stackoverflow.com/questions/38198751/domexception-error-processing-ice-candidate
1、将候选人首先push进队列;2、然后判断如果队列非空,则遍历队列执行PeerConnection.addIceCandidate()方法;
伪代码:
candidatesOnQueue.push(new RTCIceCandidate(data)); if (candidatesOnQueue.length > 0) { candidatesOnQueue.forEach(function(c) { myPeerConnection.addIceCandidate(c).catch((e) => { console.log(e); }) }); }
版权声明:除非注明,本文由( blogdaren )原创,转载请保留文章出处。
本文链接:解决WebRTC报错:DOMException: Error processing ICE candidate
发表评论: