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.
Related Reading
Guides and comparisons from the Greptile content library
What is agentic coding? Benefits, risks, and best tools to consider
What engineering leaders need to know about agentic coding: how it differs from AI coding and vibe coding, how it works, the benefits and risks, and the tools worth evaluating.
Best AI Code Review Tools for GitHub
Top-rated AI code review tools for GitHub teams in 2025. Compare features, pricing, and accuracy to find the perfect fit for faster PR reviews and bulletproof code quality.
Best Code Review Tools in 2026
The best code review tools in 2026, compared on pricing, features, deployment options, and ideal use cases for teams of any size.
Choosing the Right Code Review Tool: Better Alternatives to Graphite AI
A breakdown of the best alternatives to Graphite for code reviews. Compare AI tools like Trag, open-source solutions like Gerrit, and database-focused platforms like Visual Expert.