【问题标题】:My webRTC app is not connecting to Remote system我的 webRTC 应用程序未连接到远程系统
【发布时间】:2018-09-08 21:44:45
【问题描述】:
我在 HTTPS 服务器上运行我的 webRTC 应用程序。它运行正常,但没有获取远程系统详细信息(SDP)。
本地系统 (PC1) 和远程系统 (PC2) 都没有连接,两者都只采用本地 SDP 值。
代码link。
【问题讨论】:
标签:
javascript
node.js
webrtc
【解决方案1】:
发生的情况是远程机器和您的机器无法找到对方。他们需要一种方法来相互查找并找到网络上的连接路径,that is what STUN does。
使用免费的 STUN 服务器之一,而不是设置 const servers = null,例如 Google 的,就像这样
const servers = {'iceServers': [{'urls':'stun:stun.l.google.com:19302'}]}
在相关说明中,当您需要在所有RTCPeerConnection 对象中设置通用iceServers 时,可以使用RTCPeerConnection.defaultIceServers。所以,这也行。
RTCPeerConnection.defaultIceServers = [{'urls':'stun:stun.l.google.com:19302'}]