Registry / communication / presidium-websocket

presidium-websocket

JSON →
library4.1.0jsnpmunverified

Presidium WebSocket is a client and server library for Node.js implementing RFC 6455 (WebSocket) and RFC 7692 (Compression Extensions). Current stable version is 4.1.0. It features built-in per-message deflate compression, support for secure WebSocket (WSS) via WebSocket.SecureServer, and automatic reconnection via the connect() method. Compared to alternatives like 'ws', it offers a simpler API combining client and server in one package, and is part of the larger Presidium ecosystem. Release cadence is irregular; generally active but with infrequent updates.

npm install presidium-websocket
INSTALL
IMPORT
SIG · PRESIDIUM-WEBSOCKE
P
presidium-websocket
communicationjavascriptv4.1.0
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
const WebSocket = require('presidium-websocket')
import WebSocket from 'presidium-websocket'
Presidium-websocket is CJS-only and does not support ESM imports. Use require as shown.
WebSocket.Server
const { Server } = require('presidium-websocket')
const { WebSocketServer } = require('presidium-websocket')
The server class is exported as WebSocket.Server, not WebSocketServer. Destructure from the default export or use WebSocket.Server.
WebSocket.SecureServer
const { SecureServer } = require('presidium-websocket')
const { WebSocketSecureServer } = require('presidium-websocket')
For WSS, use SecureServer. It is not named WebSocketSecureServer.

Creates a WebSocket server and client, sends messages between them, and logs received messages.

const WebSocket = require('presidium-websocket'); const server = new WebSocket.Server(websocket => { websocket.on('message', message => { console.log('Message from client:', message); websocket.send('Hello from server!'); }); websocket.on('close', () => { console.log('websocket closed'); }); }); server.listen(1337, () => { console.log('WebSocket server listening on port 1337'); }); const websocket = new WebSocket('ws://localhost:1337/'); websocket.on('open', () => { websocket.send('Hello from client!'); }); websocket.on('message', message => { console.log('Message from server:', message); });
Debug
Known issues
gotchaESM imports (import WebSocket from 'presidium-websocket') will fail because the library is CommonJS-only.
fix
Use require instead: const WebSocket = require('presidium-websocket');
affects: >=1.0.0
gotchaThe server class is WebSocket.Server, not WebSocketServer. Wrong import leads to undefined.
fix
Use WebSocket.Server or destructure { Server } from the module.
affects: >=1.0.0
gotchaThe secure server class is WebSocket.SecureServer, not WebSocketSecureServer.
fix
Use WebSocket.SecureServer or destructure { SecureServer } from the module.
affects: >=1.0.0
deprecatedv4.0.0 changed the server listener signature from 'connection' to callback on constructor. Old code using 'connection' event listeners may stop working.
fix
Pass a callback to the WebSocket.Server constructor or use the 'connection' event on the returned server instance (check documentation).
affects: >=4.0.0 <4.1.0
Errors
Common errors & fixes
TypeError: WebSocket.Server is not a constructor
Importing incorrectly, e.g., const WebSocketServer = require('presidium-websocket').Server or using import.
fix
const WebSocket = require('presidium-websocket'); const server = new WebSocket.Server(...)
Cannot find module 'presidium-websocket'
Module not installed or wrong npm package name.
fix
Run: npm install presidium-websocket
Error: listen EADDRINUSE
Port already in use by another process.
fix
Use a different port or kill the process using the port.
TypeError: websocket.send is not a function
Calling send on a non-open WebSocket or wrong object.
fix
Ensure the WebSocket is open before sending: check readyState === 1.
Upgrade
Version history
4.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
presidium-websocket — npm install presidium-websocket · libregistry