如何检查 WebRTC 是否使用中继服务器? [英] How to check if WebRTC uses a relay server?

查看:59
本文介绍了如何检查 WebRTC 是否使用中继服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读到 WebRTC 使用中继服务器,如果直接对等连接由于防火墙而不起作用.

I read that WebRTC uses relay servers, if the direct peer connection doesn't work because of firewalls.

有没有办法检查,如果是这种情况?

推荐答案

当您建立 WebRTC 连接时,您可以设置 STUN 和/或 TURN 以供 Web 浏览器使用.如果您将这两个选项都告知 Web 浏览器,Web 浏览器将首先尝试使用 STUN.然后,如果不成功,它将尝试使用 TURN.

When you establishing WebRTC connection, you set STUN and/or TURN for a web browser to use. If you informed a web browser with the both options, web browser will start trying to use STUN first. Then, in case of unsuccess it will try to use TURN.

中继服务器"是一个 TURN 服务器.

The 'relay server' is a TURN-server.

据我所知,没有标准方法可以知道网络浏览器决定使用哪个选项:STUN 还是 TURN.

As I know, there is no standard way to know out which option a web browser decided to use: STUN or TURN.

另一方面,如果您是 TURN 服务器的所有者,您可以查看 Web 客户端是否使用它,然后将此信息发送给客户端.

In other hand, if you're the owner of TURN server, you can see whether web client does use it or not, and then send this information to the client.

更新

这是我的代码:https://github.com/fycth/webrtcexample/blob/master/www/js/rtc_lib.js

你可以看到我只使用 STUN 服务器,所以它是 p2p 或什么都没有,没有中继.

You can see there I use just STUN server, so it is p2p or nothing, and no relay.

这篇关于如何检查 WebRTC 是否使用中继服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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