Socket.io - 端口、协议和代理

发布于 2024-12-05 06:05:11 字数 264 浏览 1 评论 0原文

我正在 Nodejs 上构建一个系统Socket.io 向客户端(包括移动设备)提供实时事件。

据我所知,使用 websockets 时,由于其类似于 HTTP 的握手方式,在遍历某些代理时可能会出现问题,因此,通过使用安全的 websockets 可能会获得更高的可靠性。

避免因选择端口和协议而引起的问题非常重要。为了获得最大兼容性,端口 80 是否是避免企业等中关闭端口的最佳选择? socket.io SSL 是否与 wss 一样更可靠?

预先感谢您的建议!

I'm building a system on Nodejs & Socket.io providing real time events to clients (inc. mobile).

I understand with websockets there can be issues traversing some proxies due to its HTTP like handshake, and that you're likely to get greater reliability by using websockets secure because of it.

It is important to avoid issues caused by choice of port and protocol. For maximum compatibility would port 80 be the best choice to avoid closed ports in businesses etc? And is socket.io SSL more reliable in the same way as wss is?

Thanks in advance for the advice!

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

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

发布评论

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

评论(1

完美的未来在梦里 2024-12-12 06:05:11

SSL 不是 Node 的强项之一,但开发团队正在努力解决这一问题。所以我不会说 SSL 更可靠。

至于端口/代理.. 这是一场噩梦,您的防火墙会阻止端口 80 以外的端口。并且您有病毒扫描程序会阻止 Websocket 和其他轮询请求,并在不同的端口上允许它。

对于我们的网站,我们发现大约 5% 的访问者无法访问端口 4000。这是一个相当大的数字。

所以确实没有一个理想的端口..但是如果您只是建议您使用端口 80 并且可能提供到端口 8080 的回退,以便当您从 socket.io 收到 connect_failed 事件时,您可以尝试通过不同的端口。

在服务器端,您可能可以使用 IPTables 进行一些简单的端口转发,但我确信 google 可以告诉您更多相关信息,因为这不是我的强项;D

无论如何,希望这会有所帮助。

SSL isn't one of node's strong points, but the dev team is working hard on that. So I wouldn't say that SSL is more reliable.

As for the ports / proxies.. It's a nightmare, you have firewalls that block ports other than port 80. And you have virus scanners that block websockets and other polling requests and do allow it on different ports.

For our site we found out that about 5% of all our visitors where unable to access port 4000. Which is quite a large sum.

So there really isn't a ideal port.. But if you would just advise you to use port 80 and maybe provide a fallback to port 8080 so that when a you get a connect_failed event from socket.io you can try to connect over a different port.

On the serverside you can probably do some simple port forwarding for this using IPTables but I'm sure google could tell you more about that as it's not my strongest points ;D

Anyways, hope this helps.

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