ws: WebSocket client and server for Node.js
WebSocket client and server for Node.js with RFC 6455 support and compression.
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.
Protocol Compliance
Implements RFC 6455 WebSocket standard and passes the comprehensive Autobahn test suite for both client and server functionality.
Optional Performance
Supports bufferutil binary addon for improved frame masking performance and utf-8-validate for text validation on older Node.js versions.
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');
});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.
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.
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.
Top in Networking
Related Repositories
Discover similar tools and frameworks used by developers
ProxyChains
Force TCP connections through chained SOCKS/HTTP proxies via LD_PRELOAD.
Envoy
Cloud-native edge and service proxy with advanced load balancing, observability, and security features.
Nginx Proxy Manager
Web UI for Nginx reverse proxy and SSL management.
ByeDPI Android
Android app that bypasses DPI and network censorship using a local VPN with SOCKS5 proxy, no root required.
youtubeUnblock
Linux tool that bypasses YouTube access restrictions by manipulating SNI in network traffic.