Registry / messaging / node-red-contrib-websocket-server

node-red-contrib-websocket-server

JSON →
library0.0.9jsnpmunverified

Provides Node-RED nodes for running a WebSocket server with open/close event information. Version 0.0.9 wraps the built-in Node-RED WebSocket node and adds extra features: configurable ping/pong behavior (send ping, receive ping with timeout), ability to target specific clients via msg._session, and a dedicated node for connection open/close events. It is maintained on GitHub but has low release cadence. Key differentiators vs built-in: explicit control over ping, session-based messaging, and event nodes.

npm install node-red-contrib-websocket-server
INSTALL
IMPORT
SIG · NODE-RED-CONTRIB-W
N
node-red-contrib-websocket-server
messagingjavascriptv0.0.9
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_server
Install as a Node-RED node; appears in palette after npm install.
This is a Node-RED plugin, not imported in JavaScript code; add via manage palette or npm install.
msg._session
msg._session = 'client_id' or array of IDs
msg.session = ... or msg.clientId = ...
To target specific clients, use msg._session. Not msg.session. Case-sensitive underscore.
msg.event
msg.event === 'open' or 'close'
Output from Websocket_Open/Close node; event field indicates connection status.

Creates a basic WebSocket server node and client nodes for send/receive.

/** * Quickstart after installing node-red-contrib-websocket-server in ~/.node-red: * Restart Node-RED. Drag a Websocket_server node onto the canvas. * Set Path to '/ws' and Ping action to 'none'. * Deploy. Connect a Websocket_in node to the same path '/ws'. * Use an inject node with payload to send via Websocket_out. * Use a debug node on Websocket_in to see received messages. */ // Example flow JSON (copy to clipboard and import in Node-RED): [{"id":"n1","type":"websocket-server","path":"/ws","ping-action":"none"},{"id":"n2","type":"websocket-in","path":"/ws"},{"id":"n3","type":"websocket-out","path":"/ws"},{"id":"n4","type":"inject","payload":"Hello","target":"n3"},{"id":"n5","type":"debug","target":"n2"}]
Debug
Known issues
gotchaPath must not contain spaces or special characters: only use alphanumeric, hyphens, underscores.
fix
Use a clean path like '/ws' or '/my-websocket'.
affects: >=0.0.0
gotchaWhen using 'Send ping' option, the interval must be greater than 0. Otherwise pings are not sent.
fix
Set 'Send ping interval' to a positive number (e.g., 30).
affects: >=0.0.0
gotchamsg._session must contain an id property or an array of ids. Sending a string directly may not work as expected.
fix
Use msg._session = {id: 'client123'} or msg._session = ['client1', 'client2'].
affects: >=0.0.0
gotchaThe Websocket_Drop node requires msg._session.id; missing or incorrect format will not close the connection.
fix
Ensure input has property _session with an id (e.g., msg._session = {id: 'abc'}).
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'node-red-contrib-websocket-server'
Package not installed in the correct Node-RED user directory.
fix
Run 'npm install node-red-contrib-websocket-server' inside ~/.node-red (or your Node-RED userDir).
TypeError: Cannot read properties of undefined (reading 'id')
msg._session is missing or malformed.
fix
Set msg._session to an object with an id property, e.g., msg._session = {id: 'someClientId'}.
WebSocket connection to 'ws://...' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
Node-RED not running or wrong port/path.
fix
Ensure Node-RED is running on the expected host and port, and the path matches exactly (case-sensitive).
Upgrade
Version history
0.0.9latest on npm
Audit
Dependencies
node-redrequiredRuns as a Node-RED plugin; requires Node-RED runtime.
Agent activity
12 hits · last 30 days
node
10
Amazon
1
OpenAI (training)
1
Resources
node-red-contrib-websocket-server — npm install node-red-contrib-websocket-server · libregistry