MAO-EYE 2013-05-06 05:06 采纳率: 100%
浏览 259
已采纳

在 Node.js 中使用哪个 websocket 库? [打烊]

Currently there is a plethora of websocket libraries for node.js, the most popular seem to be:

However I can't find any solid concrete comparisons between any of them... Apparently Socket.io was awesome, but has become quite dated and has failing builds. Both ws and websocket-node claim they are the fastest. And engine.io seems new, but a lot heavier than the lighter aletarntives.

It would be amazing if we or someone could put together an answer that serves as a guide on which socket library to use and when, as well as a comparison between them.

转载于:https://stackoverflow.com/questions/16392260/which-websocket-library-to-use-with-node-js

  • 写回答

3条回答 默认 最新

  • hurriedly% 2013-05-06 06:20
    关注

    Getting the ball rolling with this community wiki answer. Feel free to edit me with your improvements.

    • ws WebSocket server and client for node.js. One of the fastest libraries if not the fastest one.

    • websocket-node WebSocket server and client for node.js

    • websocket-driver-node WebSocket server and client protocol parser node.js - used in faye-websocket-node

    • faye-websocket-node WebSocket server and client for node.js - used in faye and sockjs

    • socket.io WebSocket server and client for node.js + client for browsers + (v0 has newest to oldest fallbacks, v1 of Socket.io uses engine.io) + channels - used in stack.io. Client library tries to reconnect upon disconnection.

    • sockjs WebSocket server and client for node.js and others + client for browsers + newest to oldest fallbacks

    • faye WebSocket server and client for node.js and others + client for browsers + fallbacks + support for other server-side languages

    • deepstream.io clusterable realtime server that handles WebSockets & TCP connections and provides data-sync, pub/sub and request/response

    • socketcluster WebSocket server cluster which makes use of all CPU cores on your machine. For example, if you were to use an xlarge Amazon EC2 instance with 32 cores, you would be able to handle almost 32 times the traffic on a single instance.

    • primus Provides a common API for most of the libraries above for easy switching + stability improvements for all of them.

    When to use:

    • use the basic WebSocket servers when you want to use the native WebSocket implementations on the clientside, beware of the browser incompatabilities

    • use the fallback libraries when you care about browser fallbacks

    • use the full featured libraries when you care about channels

    • use primus when you have no idea about what to use, are not in the mood for rewriting your application when you need to switch frameworks because of changing project requirements or need additional connection stability.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 MATLAB怎么通过柱坐标变换画开口是圆形的旋转抛物面?
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿