53

8 Node.js Web Socket Libraries For 2018

 5 years ago
source link: https://www.tuicool.com/articles/hit/j6J3Urr
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

8 Node.js Web Socket Libraries For 2018

Useful libraries for working with web sockets and Node.js.

2UbmuuY.png!web

WebSockets make it possible to open an interactive communication session between the user’s browser and a server, to send messages to a server and receive event-driven responses without having to poll the server for a reply.

Although some developers choose to work with the websocket API for asynchronous communication between browsers and servers, issues such as performance, dealing with faulty connections, handling authentication and authorization, or scalability might call for a framework/library.

To help you save time, here is a short list of useful and actively maintained libraries which can come in handy. Feel free to add your own suggestions.

1. socket.io

A widely popular and used WebSocket wrapper/API with over 43K stars. Consisting of a Node.js server and a Javascript client library , socket.io provides reliability for handling proxies and load balancers as well as personal firewall and antivirus software and even supports binary streaming. Used by Microsoft, Zendesk and Trello, it even provides real time analytics and can be used for a wide verity of use cases from simple chats to IOT. Here’s a useful tutorial by @davidwalshblog .

2. ws

With 9k stars WS is a popular WebSocket is a a client/server library for Node.js that helps to manage things under the WebSocket protocol. As the WebSocket protocol is natively supported in most major browsers, some choose to work with WS directly without using socket.io on top. Here’s a quick link to the API docs and here’s a short tutorial with Node.js and express.

3. sockjs

At 6k stars sockjs is a browser JavaScript library that provides a WebSocket-like object with a cross-browser Javascript API which creates a low latency, full duplex, cross-domain communication between the browser and the web server. It follows the HTML5 websocket API and only when it fails it falls back to browser specific protocols. Sockjs-node is the client-library’s counterpart.

4. websocket node

This websocket tool for Node.js has 2k stars and is a mostly pure JavaScript implementation of the WebSocket protocol versions 8 and 13 for Node. WebSocket-Node includes both client and server functionality, available through WebSocketClient and WebSocketServer . Once a connection is established, the API for sending and receiving messages is identical. Here’s a short tutorial for building a simple chat app, and here’s a short presentation .

5. socketcluster

SocketCluster is a scalable HTTP + realtime server engine which lets you build multi-process realtime servers that make use of all CPU cores on a machine/instance. Instead of having to run the Node.js server as a single thread it makes your backend more resilient by automatically recovering from worker crashes and aggregating errors into a central log on each host. At 5k stars, It supports both direct client-server communication and group communication via pub/sub channels.

6. Feathers

At nerly 10k stars Feathers is a real-time, micro-service web framework for NodeJS that gives you control over your data via RESTful resources, sockets ( plugin ) and flexible plug-ins. The feathersjs/socketio module allows to call service methods and receive real-time events via Socket.io when working with node.js. Here’s a short tutorial for building a simple chat application.

7. faye-websocket-node

A bit old and “only” 500 stars, this project is a standards-compliant WebSocket client and server. It provides classes for building WebSocket servers and clients in Node, but not the server itself or any additional abstraction other than the standard WebSocket API (apart from eventSource connections). There also a Ruby implementation for the concept.

8. websocket as promised

A WebSocket client library providing Promise -based API for connecting, disconnecting and messaging with the server. It’s basically a simple request-response mechanism that returns a promise. To work with Node.js, it should be combined with a third-party node server library like websockets-node. Although only at 200 stars, The project is still under active development.

Honorable mentions

Note that these projects are mostly unmaintained.

  • nodejs-websocket
  • Primus
  • Express-ws
  • Pushers-js
  • Totaljs

Meet Bit

Bit is an open source platform for easily sharing code between Javascript projects to speed development. Using Bit you can seamlessly share, use, develop and sync components and modules from different project and collaborate as a team to build faster. Check it out.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK