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条)

报告相同问题?

悬赏问题

  • ¥100 在连接内网VPN时,如何同时保持互联网连接
  • ¥15 MATLAB中使用parfor,矩阵Removal的有效索引在parfor循环中受限制
  • ¥20 Win 10 LTSC 1809版本如何无损提升到20H1版本
  • ¥50 win10 LTSC 虚拟键盘不弹出
  • ¥30 关于PHP中POST获取数据的问题
  • ¥30 微信小程序请求失败,网页能正常带锁访问
  • ¥15 Python实现hog特征图可视化
  • ¥30 德飞莱51单片机实现C4炸弹
  • ¥50 CrossLink-LIF-MD6000 型 FPGA 的 CMOS 转 MIPI D-PHY IP 核功能使用异常
  • ¥15 proteus控制16x16LED点阵显示屏的设计