Navigate:
~$WS0.1%

ws: WebSocket client and server for Node.js

WebSocket client and server for Node.js with RFC 6455 support and compression.

LIVE RANKINGS • 12:15 PM • STEADY
OVERALL
#355
6
NETWORKING
#17
30 DAY RANKING TREND
ovr#355
·Netwo#17
STARS
22.7K
FORKS
2.5K
7D STARS
+19
7D FORKS
0
See Repo:
Share:

Learn more about ws

ws is a WebSocket library that implements the RFC 6455 WebSocket protocol for Node.js applications. It provides both client and server classes that handle WebSocket connections, message framing, and protocol negotiation. The library supports optional extensions like permessage-deflate compression and can integrate with existing HTTP/HTTPS servers. It is commonly used for real-time communication in web applications, chat systems, and live data streaming.

ws

1

Protocol Compliance

Implements RFC 6455 WebSocket standard and passes the comprehensive Autobahn test suite for both client and server functionality.

2

Optional Performance

Supports bufferutil binary addon for improved frame masking performance and utf-8-validate for text validation on older Node.js versions.

3

Compression Support

Includes permessage-deflate extension with configurable parameters for message compression, though disabled by default on servers due to performance overhead.


import { WebSocketServer } from 'ws';

const wss = new WebSocketServer({ port: 8080 });

wss.on('connection', function connection(ws) {
  ws.on('error', console.error);

  ws.on('message', function message(data) {
    console.log('received: %s', data);
  });

  ws.send('something');
});


v8.19.0

Added the closeTimeout option and handled a forthcoming breaking change in Node.js core.

  • Added the closeTimeout option.
  • Handled a forthcoming breaking change in Node.js core.
v8.18.3

Fixed a spec violation where the Sec-WebSocket-Version header was not added to HTTP responses for invalid client versions.

  • Fixed a spec violation where the Sec-WebSocket-Version header was not added to the HTTP response if the client requested version was either invalid or unsupported.
v8.18.2

Fixed an issue during message decompression when the maximum size was exceeded that led to inaccurate errors.

  • Fixed an issue that, during message decompression when the maximum size was exceeded, led to the emission of an inaccurate error and closure of the connection.


[ EXPLORE MORE ]

Related Repositories

Discover similar tools and frameworks used by developers