Registry / messaging / ws-rpc

ws-rpc

JSON →
library0.0.8jsnpmunverified

ws-rpc is a lightweight RPC extension for the ws WebSocket server, enabling named message types and callback-based communication for server and client. Version 0.0.8 is the latest release, with no recent updates (low activity). It provides room/channel support, client disconnect auto-removal, and integration with Express and Flash client shims. Unlike raw ws, it adds structured RPC patterns on top, but binary messages are handled separately.

npm install ws-rpc
INSTALL
IMPORT
SIG · WS-RPC
W
ws-rpc
messagingjavascriptv0.0.8
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.

extend
const wsrpc = require('ws-rpc').extend(wss);
const wsrpc = require('ws-rpc');
extend is a static method on the ws-rpc module, not the default export.
middleware
app.use(require('ws-rpc').middleware(express));
app.use(require('ws-rpc').middleware);
middleware is a function that takes express as argument.
WsRpcClient
Using the global object from /ws-rpc-client.min.js
import { WsRpcClient } from 'ws-rpc';
The browser client is a standalone script, not bundled in the npm package for Node.js. Use it as a global.

Basic server setup with Express, ws, and ws-rpc: create room, handle connect, message, disconnect, error events.

var prod = process.env.NODE_ENV === 'production'; var app = require('express').createServer(); var wss = new (require('ws').Server)({ server: app }); var wsrpc = require('ws-rpc').extend(wss); app.listen(prod ? 80 : 1234); var myRoom = wss.room('myRoom'); wss.on('connect', function(client) { myRoom.add(client); client.message('some message', 'hello'); }); wss.on('some message', function(client, args) { console.log('received', args); }); wss.on('disconnect', function(client) { console.log('client disconnected'); }); wss.on('error', function(e, client) { console.log(client ? 'client' : 'server', e); });
Debug
Known issues
deprecatedws-rpc is no longer actively maintained. Last release in 2013. Consider using modern alternatives like Socket.IO or raw ws with custom RPC.
fix
Migrate to Socket.IO or use ws directly with JSON messages.
affects: *
breakingBinary messages are not handled by the RPC extension.
fix
Handle binary messages separately using the classic ws API on 'message' event with flags.
affects: *
gotchaThe 'connect' vs 'connection' event naming: ws-rpc uses 'connect', while ws uses 'connection'. Ensure you do not mix them.
fix
Use wss.on('connect', ...) for ws-rpc, and wss.on('connection', ...) only when bypassing RPC.
affects: *
Errors
Common errors & fixes
TypeError: Object #<Object> has no method 'extend'
Incorrect require or using wrong module export.
fix
Use const wsrpc = require('ws-rpc').extend(wss); not require('ws-rpc')(wss);
ReferenceError: WsRpcClient is not defined
Browser client script not loaded or loaded out of order.
fix
Include <script src='/ws-rpc-client.min.js'></script> before your client code.
Error: listen EADDRINUSE
Port already in use, often due to race condition or other server.
fix
Ensure no other process uses the same port, or use app.listen(port, callback).
Upgrade
Version history
0.0.8latest on npm
Audit
Dependencies
wsrequiredpeer dependency: ws-rpc extends the ws WebSocket server
Agent activity
29 hits · last 30 days
node
26
OpenAI (training)
1
Resources
packagews-rpc
ws-rpc — npm install ws-rpc · libregistry