如何让服务器通知防火墙后面的客户端

发布于 2024-08-17 04:03:21 字数 370 浏览 8 评论 0原文

我的情况是,我在互联网上有一个面向公众的服务,我希望服务器能够在需要时联系位于普通家庭网络中的专门设计的嵌入式设备。

我知道设备可以轮询服务器以获取更新等,但是 1)服务器执行某些操作与设备轮询更新之间会有延迟,2)会生成大量无用的流量(随着时间的推移)。

有人对如何做到这一点有任何建议吗?我最初的想法是让嵌入式设备使用 UPNP 尝试在家庭路由器中生成端口转发规则,然后将该端口注册到服务器。然后,服务器可以生成到该地址的 HTTP 请求(http 以便它将被路由等,而不会被防火墙等一路阻止)。如果设备无法创建转发规则,那么它将诉诸轮询方法。

这听起来正确吗?任何人有任何关于此类事情的经验可以分享吗? (客户端将是嵌入式 Linux 上的 C++,服务器是 .NET)。

I have the case where I have a public facing service sitting out on the internet and I would like the ability for the server to contact specifically design embedded devices that are sitting in normal home networks when required.

I know that the devices can poll the server to get updates etc but 1) There will be a lag between when server does something, and device polls for update and 2) There will be a lot of useless traffic (over time) generated.

Does anyone have any suggestions on how to do this? My initial though is to have the embedded devices use UPNP to try and generate a port forward rule in the home router, and then register that port to the server. The server can then generate a HTTP request to that address (http so that it will get routed etc without being blocked by firewalls etc along the way). If the device cant create the forward rule then it will resourt back to the polling method.

Does this sound about right? Anyone have any experience they could share with this sort of thing? (Client will be c++ on embedded linux, server .NET).

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

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

发布评论

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

评论(1

孤独岁月 2024-08-24 04:03:21

很大程度上取决于您认为要使用的设备/网络数量以及您对其软件/配置的控制权。

由于您谈论的是 UPNP,这意味着将会有很多客户端网络 - 除非您可以控制路由器配置/硬件,否则在使 UPNP 解决方案可靠工作方面将会遇到很多问题。

另外,您提到端口转发,这表明嵌入式设备不会有真正的 IP 地址。

您说您想使用 HTTP 来避免它被阻止,但是大多数防火墙/路由器等并不是那么智能 - 阻止纯粹是在端口号上完成的。如果 NAT 路由器后面有多个设备,则必须使用非标准端口来寻址设备,除非您实现控制器来基于 HTTP 内容中继请求。

我能看到的唯一实用的解决方案是让嵌入式设备连接到服务器并等待事件发生。

C.

A lot depends on how many devices / networks you think this going to be used with and what control you have over their software/configuration.

Since you're talking about UPNP, it implies that there will be lots of client networks - unless you have control over the router config / hardware, you're going to have lots of problems getting the UPNP solution to work reliably.

Also, you mention portforwarding which rather suggests that the embedded devices will not have real IP addresses.

You say that you want to use HTTP to avoid it being blocked however the majority of firewalls/routers etc aren't that smart - blocking is done purely on port numbers. If you've got multiple devices behind a NAT router, then you'll have to use non-standard ports to address the devices unless you implement a controller to relay requests based on the HTTP content.

The only practical solution I can see is having the embedded devices connect to the server and wait for an event to occur.

C.

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