PeerJS可以在不访问互联网的情况下制作本地流吗

发布于 2025-01-14 08:46:10 字数 957 浏览 6 评论 0原文

我完成了对等JS服务器的设置,遵循这个url https://github.com/peers/peerjs-server。 设置遵循nodeJs + Express。

输入图片这里的描述

我还使用 Angular 应用程序设置客户端 PeerJs。当我连接到互联网时一切都很好。但一旦互联网关闭连接,我就会收到错误。我尝试让我的应用程序在本地网络中运行而无需访问互联网。

以下是我的peerJs 客户端配置。

输入图片这里的描述

我还在角度应用程序中将peerjs导入为本地。

输入图片此处描述

在没有互联网连接的情况下启动应用程序时会出现以下错误。

输入图片这里的描述

任何人都可以建议在本地设置peerJs而无需访问互联网吗?

I done setup peerJS server follow this url https://github.com/peers/peerjs-server.
Setup follow by nodeJs + express.

enter image description here

I also setup client peerJs using angular Apps. Everything is fine when I have connection with internet. But I getting error once internet close connection. I try to make my apps running in local network without access internet.

Below is my configuration if peerJs client.

enter image description here

I also import peerjs as local in angular apps.

enter image description here

Below error appear once start apps without internet connection.

enter image description here

Any one can advise for setup peerJs locally without access internet?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷情妓 2025-01-21 08:46:10

PeerJS 服务器充当 WebRTC 信令服务器。

如果您在本地 (Wi-Fi) 网络中本地运行 PeerJS 服务器,并且您的对等方(客户端)位于同一网络中,则不需要互联网连接。

如果您的 PeerJS 服务器在不同的网络中可用(通过互联网),您的客户端可以选择以下选项:

  1. 建立互联网连接几秒钟:连接到 PeerJS 服务器,然后连接到对等点。现在您可以与 PeerJS 服务器断开连接(如果其他客户端仍在同一本地网络中,则可以与互联网断开连接)

  2. 如果另一个对等点位于同一本地网络中,您需要自己发送信号。

要向自己发出信号,您可以检查此代码: https://github.com/lesmana/ webrtc-without-signaling-server

这是一个演示/gif:https://mac-blog.org.ua/webrtc-one-to-one-without-signaling-server

在现实世界中,还存在一些其他障碍,例如防火墙和 NAT。为了解决这些问题,您需要 STUN 甚至 TURN(中继)服务器。

PeerJS server acts as a WebRTC signaling server.

If you're running PeerJS server locally in your local (Wi-Fi) network and your peers (clients) are in the same network, you don't need an internet connection.

If your PeerJS server is available in a different network (via internet), you have these options for your clients:

  1. establish an internet connection for a few seconds: connect to the PeerJS server, then connect to a peer. Now you can disconnect from the PeerJS server (and from the internet if the other client is still in the same local network)

  2. if the other peer is in the same local network, you need to do the signaling yourself.

To do signaling yourself you can check this code: https://github.com/lesmana/webrtc-without-signaling-server

here is a demo/gif: https://mac-blog.org.ua/webrtc-one-to-one-without-signaling-server

In a real world there are some other obstacles like firewalls and NAT. To solve them you need a STUN or even a TURN (relay) server.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文