Registry / messaging / postman-ws

postman-ws

JSON →
library7.4.5-postman.1jsnpmunverified

Postman's fork of the ws WebSocket library for Node.js. Version 7.4.5-postman.1 provides a simple to use, blazing fast, and thoroughly tested WebSocket client and server implementation. It passes the Autobahn test suite and supports HyBi drafts 07-17, permessage-deflate compression, and binary data. Notable differences from the original ws: maintained by Postman for internal use, includes potential patches or compatibility fixes. Release cadence follows upstream ws development. Key differentiator: same API as ws but with Postman-specific modifications. Requires Node.js >=8.3.0, optional dependencies bufferutil and utf-8-validate for performance.

npm install postman-ws
INSTALL
IMPORT
SIG · POSTMAN-WS
P
postman-ws
messagingjavascriptv7.4.5-postman.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

WebSocket
import WebSocket from 'ws'
const WebSocket = require('ws').WebSocket
Default export is the WebSocket class. CommonJS users can do const WebSocket = require('ws');
WebSocketServer
import { WebSocketServer } from 'ws'
import WebSocketServer from 'ws'
Named export, not default. Also accessible via WebSocket.Server.
WebSocket (type)
import type { WebSocket } from 'ws'
import { WebSocket } from 'ws'
When using TypeScript, use 'import type' for type-only imports to avoid runtime overhead.

Shows how to create a WebSocket server and client using the ws library, with event handling for connection, open, and message.

import WebSocket from 'ws'; import { WebSocketServer } from 'ws'; const wss = new WebSocketServer({ port: 8080 }); wss.on('connection', function connection(ws) { ws.on('message', function incoming(data) { console.log('received: %s', data); }); ws.send('something'); }); const ws = new WebSocket('ws://localhost:8080'); ws.on('open', function open() { ws.send('Hello, server!'); }); ws.on('message', function incoming(data) { console.log('received from server: %s', data); });
Debug
Known issues
gotchaThis package is a Postman-specific fork of ws. It may contain changes not present in the original ws package.
fix
Use the original ws package unless you need Postman-specific modifications.
affects: >=7.4.5-postman.1
breakingThe module does not work in the browser. The client API is for Node.js.
fix
Use native WebSocket API or isomorphic-ws for browser/Node.js compatibility.
affects: all
deprecatedThe 'WebSocketServer' constructor is the recommended way, not 'WebSocket.Server'.
fix
Use import { WebSocketServer } from 'ws' instead of WebSocket.Server.
affects: >=7
gotchaPer message deflate compression is disabled by default on the server, enabled by default on the client.
fix
Explicitly configure perMessageDeflate option if needed.
affects: >=7
breakingThe 'close' event does not expose the close reason in the event object.
fix
Access 'code' and 'reason' from the WebSocket 'close' event's first argument.
affects: <7
Errors
Common errors & fixes
Error: getaddrinfo ENOTFOUND <host>
DNS resolution failure when connecting to WebSocket server.
fix
Ensure the hostname is correct and DNS is configured properly.
WebSocket connection to 'ws://...' failed: Error: Unexpected server response: 401
Server returned unauthorized response due to missing or invalid authentication.
fix
Set headers on the WebSocket constructor, e.g., new WebSocket('ws://...', { headers: { Authorization: 'Bearer token' } })
Error: read ECONNRESET
Connection abruptly closed by the remote end.
fix
Handle the 'error' and 'close' events properly to detect and reconnect.
Upgrade
Version history
7.4.5-postman.1latest on npm
Audit
Dependencies
bufferutiloptionalOptional addon for efficient masking/unmasking of WebSocket frames
utf-8-validateoptionalOptional addon for efficient UTF-8 validation
Agent activity
15 hits · last 30 days
node
14
OpenAI (training)
1
Resources
postman-ws — npm install postman-ws · libregistry