javascript - 为什么 null 几乎总是传递给 RTCPeerConnection?

标签 javascript html webrtc

几乎我在 Internet 上看到的每个 WebRTC 示例都涉及创建一个带有单个参数 nullRTCPeerConnectionThe spec calls for two parameters待通过:ICE 服务器配置和您的媒体限制。

我注意到,如果传递 null(例如,var pc = new RTCPeerConnection(null);)。我不确定它是否适用于跨网络。有人可以在这里进一步说明发生了什么吗?

最佳答案

Nearly every example of WebRTC I've seen on the Internet involves creating a RTCPeerConnection with a single parameter of null.

我想对于这些示例,大多数时候都假定您在同一台计算机上。所以你真的不需要任何iceServers。 (而且示例不想为您提供“免费”的 stun-server/turn-server?)

I've noticed that technically everything still works if the two requests are coming from the same router when you pass null.

如果客户端不在同一个网络上,则不会出现这种情况。因为没有 stun 服务器(通过 iceServers 配置传递),客户端无法获得他们的服务器反射地址。

编辑:

正如 @syno 的评论中指出的那样:

目前,webRTC 的“安全”问题之一是 STUN 和 TURN 服务器配置在创建对等连接时以明文形式传递。任何人都可以查看 JavaScript 代码并使用您的服务器。这就是为什么必须使用带有 REST API (code.google.com/p/rfc5766-turn-server/wiki/turnserver) 的 TURN 服务器来获得临时“时间戳”以限制不需要的用户的使用。当目的是学习或展示 webRTC 的基本概念时,不需要在一个简单的演示中添加所有这些复杂性

关于javascript - 为什么 null 几乎总是传递给 RTCPeerConnection?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28335606/

相关文章:

javascript - 不要在循环中创建函数 no-loop-func Axios Request async await

javascript - 从父级下拉菜单中 react 设置子级状态

javascript - WebRTC 从不触发 IceCandidate

javascript - 在 Web RTC 中使用音频捕获作为 MediaStream 源

html - 在图片下方排列文字

javascript - 从外部 LAN 访问网络摄像机,无需端口转发

javascript - jQuery HTML - 移动设备 : onclick not working as long as input is active

javascript - Jquery:根据相同的输入名称检查重复的值

php - 在 Twiiter Bootstrap v2 中整合 Typeahead/JSON 数据源?

html - IE窗口缩小时DIV溢出外层DIV(Restore-Down)