Registry / communication / n8n-nodes-websocket

n8n-nodes-websocket

JSON →
library1.0.1jsnpmunverified

Enhanced WebSocket nodes for n8n (v1.0.1) providing real-time bidirectional communication between workflows and external applications, including a WebSocket trigger (server) and a WebSocket response node. Features include broadcast, reply-to-sender, targeted messaging, authentication via tokens/query parameters, heartbeat, and connection management. Released under MIT, maintained on GitHub, requires n8n-workflow as a peer dependency. Regularly updated, with community support.

npm install n8n-nodes-websocket
INSTALL
IMPORT
SIG · N8N-NODES-WEBSOCKE
N
n8n-nodes-websocket
communicationjavascriptv1.0.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.

WebSocketTrigger
import { WebSocketTrigger } from 'n8n-nodes-websocket'
import WebSocketTrigger from 'n8n-nodes-websocket'
Named export only; default import is not available.
WebSocketResponse
import { WebSocketResponse } from 'n8n-nodes-websocket'
const WebSocketResponse = require('n8n-nodes-websocket').WebSocketResponse
ESM import is required for use in n8n's module system; commonjs require may not work in all environments.
WebSocketTrigger (type)
import type { WebSocketTrigger } from 'n8n-nodes-websocket'
Use import type if only using for TypeScript type annotations, not for runtime.

Shows minimal setup for an echo server using WebSocketTrigger and WebSocketResponse nodes in n8n.

import { WebSocketTrigger, WebSocketResponse } from 'n8n-nodes-websocket'; // In n8n workflow, add WebSocketTrigger node configured: // Port: 8080, Path: /echo, Trigger On: Message // Then WebSocketResponse node: // Operation: Reply to Sender, Connection ID Source: From Input Data, Message: Echo: {{$json.data}} // Test with client: // const ws = new WebSocket('ws://localhost:8080/echo'); // ws.onopen = () => ws.send('Hello World!'); // ws.onmessage = (event) => console.log(event.data); // Echo: Hello World!
Debug
Known issues
gotchaWebSocket server binds to 0.0.0.0 by default, exposing it to external connections.
fix
Set Bind Address to 'localhost' in node configuration to restrict connections.
affects: >=1.0.0
gotchaConnection ID (connId) must be passed correctly; using wrong property name causes silent failures.
fix
Ensure data includes property 'connectionId' (camelCase) when sending to specific connection.
affects: >=1.0.0
deprecatedOlder node configurations using 'Reply to Client' operation name are deprecated.
fix
Update to use 'Reply to Sender' as operation name.
affects: <1.0.1
gotchaHeartbeat interval too low can cause CPU spikes with many connections.
fix
Set Heartbeat Interval to at least 30 seconds for production.
affects: >=1.0.0
breakingBreaking change: v1.0.0 changed output JSON structure from 'data.message' to 'data.data'.
fix
Update workflow expressions that reference $json.data.message to $json.data.data.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'n8n-workflow'
Missing peer dependency n8n-workflow
fix
npm install n8n-workflow --save
TypeError: WebSocketTrigger is not a constructor
Using default import instead of named import
fix
Change to import { WebSocketTrigger } from 'n8n-nodes-websocket'
WebSocket server not receiving connections on port 8080
Port already in use or firewall blocking
fix
Check port availability with 'netstat -an | grep 8080' or use a different port
Response node says 'No active connection found'
Connection ID expired or connection closed
fix
Ensure WebSocket client is still connected and connectionId is valid
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
n8n-workflowrequiredPeer dependency required for n8n node integration
Agent activity
17 hits · last 30 days
node
14
Amazon
1
OpenAI (training)
1
Resources
n8n-nodes-websocket — npm install n8n-nodes-websocket · libregistry