A complete WebSocket protocol implementation with pluggable I/O, extracted from the Faye project. Current stable version 0.7.5, released August 2020. Supports RFC 6455, draft-75, and draft-76. Handles handshake negotiation, subprotocol selection, extensions via websocket-extensions, message framing (text, binary, ping, pong, close), fragmentation, masking, and close handshake. Decouples protocol details from I/O, allowing use with HTTP servers (http.createServer) or raw TCP (net module). Typically used as a low-level library by higher-level WebSocket libraries like faye-websocket.
npm install websocket-driverNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to attach a WebSocket driver to an HTTP upgrade event, pipe the socket, and handle incoming messages.
After creating the driver, write the 'body' buffer to driver.io immediately.
Use driver.messages.on('data', callback) or pipe to another stream.Listen for 'connect' on the driver and then call websocket.isWebSocket(driver) to check.
Ensure driver.io.write(body) is called before piping the socket: driver.io.write(body); socket.pipe(driver.io).pipe(socket);
Verify the driver is created via websocket.http(request) or websocket.server() and that driver.start() is called.
Ensure you have imported the module: import websocket from 'websocket-driver' or const websocket = require('websocket-driver').