我在HTTPS服务器上运行webRTC应用程序。它运行正常,但它没有采用远程系统详细信息(SDP)。本地系统(PC1)和远程系统(PC2)都没有连接,两者都只采用本地SDP值。
代码link。
发生的事情是远程机器和您的机器无法找到对方。他们需要一种相互查找的方法,并在网络上找到一条连接路径,that is what STUN does。
而不是设置const servers = null
,使用其中一个免费的STUN服务器,比如Google,就像这样
const servers = {'iceServers': [{'urls':'stun:stun.l.google.com:19302'}]}
在相关的说明中,当您需要在所有RTCPeerConnection.defaultIceServers对象中设置公共iceServers时,可以使用RTCPeerConnection
。所以,这也会奏效。
RTCPeerConnection.defaultIceServers = [{'urls':'stun:stun.l.google.com:19302'}]