检查 WebRTC 连接 - 可靠的方法 [英] Checking for WebRTC connectivity - reliable methods

查看:72
本文介绍了检查 WebRTC 连接 - 可靠的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个实时视频聊天应用程序,我使用支持 STUN/TURN 和 UPD/TCP 传输的 TURN 服务器.

I have a live video chat application and I use a TURN server which supports STUN/TURN and both UPD/TCP transmission.

有时用户可以连接到网络,这阻止WebRTC连接只是无法发生的那么多端口和协议(通常是公司网络).我想在用户尝试相互连接之前检查 WebRTC 连接是否可行(实际上,执行技术检查).

Sometimes users can be connected to the network which blocks that much ports and protocols that WebRTC connection just cannot happen (usually those are corporate networks). I would like to check if a WebRTC connection is possible before users try to connect to each other (actually, perform a technical check).

我该怎么做?我脑子里的想法:

How can I do it? Ideas I have in my head:

  1. 尝试通过 WebRTC下载托管的数据块(例如音频文件) - 是否可行,这是否足以确保入站和出站连接都打开?
  2. 使用 TURN 服务器作为主机 建立连接并查看它是否失败(不知道我是否可以这样做)
  3. 使用 Flash 尝试通过特定端口和协议下载/上传大量数据.甚至可能使用 Cirrus.但是,我不确定从 WebRTC 的角度来看这个测试是否准确.
  4. 还有其他想法吗?
  1. Try to download a hosted chunk of data (audio file, for example) via WebRTC - is it possible and would this be enough to make sure both inbound and outbound connections are open?
  2. Use a TURN server as a host to make a connection to and see if it fails (have no idea if I can do it or not)
  3. Use Flash to try to download/upload a chunk of data over specific ports and protocols. May be even using Cirrus. However, I am not sure this test will be accurate from WebRTC prospective.
  4. Any other ideas?

附加要求:检查技术必须支持 Chrome、Opera 和 Firefox.最好还通过 Temasys 插件访问 IE/Safari.

第 1 版 - 收集 ICE 候选人是个好主意,但它并非 100% 可靠.一旦我检查了我的应用程序中的日志,它实际上收集了中继 ICE 候选者,但视频/音频传输失败.在 Apprtc 上也进行了测试,得到了相同的结果.

推荐答案

典型的 WebRTC 方法是创建与 STUN 和 TURN 服务器的对等连接,调用 createOffer 和 setLocalDescription 并观察收集的候选人.参见例如http://webrtc.github.io/samples/src/content/对等连接/涓流冰/

the typical WebRTC approach to this is to create a peerconnection with STUN and TURN servers, call createOffer and setLocalDescription and watch the candidates gathered. See e.g. http://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/

如果您获得 srflx 候选者,则您的 stun 服务器可以工作(即 UDP 未被阻止).更有趣的是你是否得到接力候选人.如果你这样做,使用 TURN 作为后备将起作用.如果使用 TURN/TCP,质量可能会受到影响.如果你没有得到接力候选人......电话不太可能奏效.

If you get srflx candidates, your stun server works (i.e. UDP is not blocked). More interesting is whether you get relay candidates. If you do, using TURN as a fallback will work. Quality might suffer if TURN/TCP is used. If you don't get relay candidates... calls are very unlikely to work.

这篇关于检查 WebRTC 连接 - 可靠的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆