如何在没有Internet连接的情况下通过本地网络进行WebRTC? [英] How can you do WebRTC over a local network with no internet connection?

查看:224
本文介绍了如何在没有Internet连接的情况下通过本地网络进行WebRTC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让两台不同的计算机打开一个静态html页面,并能够通过局域网上的WebRTC相互通信.在这种情况下,没有与外界的Internet连接.其中一台电脑将能够手动输入另一台电脑的IP地址,并使用该硬编码IP连接到它. ICE服务器是必需的吗?如果是这样,服务器本身是否需要互联网连接到外部世界?

I want to have two different computers open a static html page, and be able to communicate to each other via WebRTC over a local area network. There is no internet connection to the outside world in this scenario. One of the pcs would be able to enter the ip address of the other pc manually and connect to it using that hardcoded IP. Is an ICE server necessary? If so, does the server itself need internet access to the outside world?

推荐答案

在这种情况下,您不需要ICE服务器.通常,您通常具有以下ICE候选人:

You do not need ICE servers in this case. In general, you have the following ICE candidates normally:

  • 主机(由客户端通过绑定到其本地分配的IP地址和端口来生成)
  • srflx(使用STUN生成服务器反射候选)
  • 中继(通过使用TURN生成中继候选)

因此,没有ICE服务器,您将仅生成主机个候选者,对于您的情况,这是足够的,因为两个用户都在同一个本地网络中.

So without ICE servers you will have only host candidates generated which is enough in your case because both users are in the same local network.

尽管WebRTC启用了对等通信,但它仍需要一个用于发信号的服务器:启用媒体和网络元数据的交换以引导对等连接.

Although WebRTC enables peer-to-peer communication, it still needs a server for signaling: to enable the exchange of media and network metadata to bootstrap a peer connection.

因此,这里的主要问题是,您需要以某种方式在端点之间交换要约"和答案",因此,每一方都将拥有彼此足够的信息.通常,为此目的使用一些信令协议+公共服务器.

So the main problem here is that you need to exchange the "offer" and "answer" between endpoints somehow, so each party will have enough information about each other. Normally, some signaling protocol + public server is used for this purpose.

在您的情况下,您有3种选择:

In your case, you have 3 choices:

  • 在两个浏览器之间建立直接的p2p WebSocket连接.不知道是否可能.看起来浏览器只能连接到其他端点,而不能监听.
  • 手动复制\粘贴报价"和答案" SDP,我认为这也不好
  • 有一台安装了信令服务器的第三台计算机,因此其他对等方将使用它在彼此之间交换要约"和答案"

这篇关于如何在没有Internet连接的情况下通过本地网络进行WebRTC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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