问题描述
Socket.IO 似乎是最流行和最活跃的 WebSocket 仿真库.Juggernaut 使用它来创建一个完整的发布/订阅系统.
Socket.IO seems to be the most popular and active WebSocket emulation library. Juggernaut uses it to create a complete pub/sub system.
Faye 也很受欢迎和活跃,并且有自己的javascript库,功能齐全可以媲美剑圣.Juggernaut 使用 node 作为其服务器,Faye 可以使用 node 或 rack.Juggernaut 使用 Redis 进行持久化(更正:它使用 Redis 进行发布/订阅),而 Faye 仅将状态保存在内存中.
Faye is also popular and active, and has its own javascript library, making its complete functionality comparable to Juggernaut. Juggernaut uses node for its server, and Faye can use either node or rack. Juggernaut uses Redis for persistence (correction: it uses Redis for pub/sub), and Faye only keeps state in memory.
- 以上所有内容都准确吗?
- Faye 说它实现了 Bayeux -- 我认为 Juggernaut 不会这样做-- 是不是因为Juggernaut级别比较低(IE,我可以用Juggernaut实现Bayeux)
- 如果 Faye 愿意,可以切换到使用 Socket.IO 浏览器 javascript 库吗?还是他们的 javascript 库做了根本不同的事情?
- 项目之间是否存在任何其他建筑/设计/哲学差异?
- Is everything above accurate?
- Faye says it implements Bayeux -- i think Juggernaut does not do this -- is that because Juggernaut is lower level (IE, I can implement Bayeux using Juggernaut)
- Could Faye switch to using the Socket.IO browser javascript library if it wanted to? Or do their javascript libraries do fundamentally different things?
- Are there any other architectural/design/philosophy differences between the projects?
推荐答案
披露:我是 Faye 的作者.
- 关于 Faye,你说的都是真的.
- Faye 实现了 Bayeux 的大部分内容,现在唯一缺少的是服务渠道,我还没有相信它的用处.特别是 Faye 旨在与 Bayeux 的 CometD 参考实现兼容,这对以下内容有很大影响.
- 从概念上讲,是的:Faye 可以使用 Socket.IO.在实践中,这有一些障碍:
- 我不知道 Socket.IO 需要什么样的服务器端支持,以及 Faye 客户端(在 Node 和 Ruby 中有服务器端客户端,记住)能够与任何 Bayeux 服务器通信的要求(和 Faye 服务器到任何 Bayeux 客户端)可能会破坏交易.
- Bayeux 对服务器和客户端支持某些传输类型有特定要求,并说明如何协商使用哪种传输类型.它还指定了它们的使用方式,例如 XHR 请求的 Content-Type 如何影响其内容的解释方式.
- 对于某些类型的错误处理,我需要直接访问传输,例如 在 Node WebSocket 终止后客户端重新连接时重新发送消息.
- 如果我有任何错误,请纠正我 - 这是基于对 Socket.IO 文档的粗略扫描.
- Regarding Faye, everything you've said is true.
- Faye implements most of Bayeux, the only thing missing right now is service channels, which I've yet to be convinced of the usefulness of. In particular Faye is designed to be compatible with the CometD reference implementation of Bayeux, which has a large bearing on the following.
- Conceptually, yes: Faye could use Socket.IO. In practise, there are some barriers to this:
- I've no idea what kind of server-side support Socket.IO requires, and the requirement that the Faye client (there are server-side clients in Node and Ruby, remember) be able to talk to any Bayeux server (and the Faye server to any Bayeux client) may be deal-breaker.
- Bayeux has specific requirements that servers and clients support certain transport types, and says how to negotiate which one to use. It also specifies how they are used, for example how the Content-Type of an XHR request affects how its content is interpreted.
- For some types of error handling I need direct access to the transport, for example resending messages when a client reconnects after a Node WebSocket dies.
- Please correct me if I've got any of this wrong - this is based on a cursory scan of the Socket.IO documentation.
- 服务器端和客户端扩展
- 通道路由上的通配符模式匹配
- 自动重新连接,例如当 WebSockets 死掉或服务器离线时
- 客户端适用于所有浏览器、手机以及 Node 和 Ruby 的服务器端
与 Juggernaut 相比,Faye 可能看起来要复杂得多,因为 Juggernaut 代表更多,例如它将传输协商委托给 Socket.IO,并将消息路由委托给 Redis.这些都是很好的决定,但我决定使用 Bayeux 意味着我必须自己做更多的工作.
Faye probably looks a lot more complex compared to Juggernaut because Juggernaut delegates more, e.g. it delegates transport negotiation to Socket.IO and message routing to Redis. These are both fine decisions, but my decision to use Bayeux means I have to do more work myself.
至于设计理念,Faye 的首要目标是它应该在 Web 可用的任何地方都可以使用,并且应该非常容易上手.入门真的很简单,但它的可扩展性意味着它可以以非常强大的方式进行自定义,例如,您可以通过添加身份验证扩展将其转换为服务器到客户端推送服务(即停止任意客户端推送到它).
As for design philosophy, Faye's overriding goal is that it should work everywhere the Web is available and should be absolutely trivial to get going with. I'ts really simple to get started with but its extensibility means it can be customized in quite powerful ways, for example you can turn it into a server-to-client push service (i.e. stop arbitrary clients pushing to it) by adding authentication extensions.
还有一些工作正在进行中,以使其在服务器端更加灵活.我正在考虑添加集群支持,并使核心发布-订阅引擎可插拔,以便您可以将 Faye 用作另一个发布-订阅系统(如 Redis 或 AMQP)的无状态 Web 前端.
There is also work underway to make it more flexible on the server side. I'm looking at adding clustering support, and making the core pub-sub engine pluggable so you could use Faye as a stateless web frontend for another pub-sub system like Redis or AMQP.
我希望这对您有所帮助.
I hope this has been helpful.
这篇关于Faye 与 Socket.IO(和 Juggernaut)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!