
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
n8n-nodes-websocket
Advanced tools
Enhanced WebSocket nodes for n8n with bidirectional communication support
Enhanced WebSocket nodes for n8n that enable bidirectional real-time communication between your workflows and external applications.

0.0.0.0 for external connections or localhost for local onlyn8n-nodes-websocket# Navigate to your n8n installation directory
cd ~/.n8n
# Install the package
npm install n8n-nodes-websocket
# Restart n8n
Add to your Dockerfile:
RUN cd /usr/local/lib/node_modules/n8n && npm install n8n-nodes-websocket
Create a simple WebSocket server that echoes back any message:
8080/echoMessageReply to SenderFrom Input DataEcho: {{$json.data}}Test it:
const ws = new WebSocket('ws://localhost:8080/echo');
ws.onopen = () => ws.send('Hello World!');
ws.onmessage = (event) => console.log(event.data); // "Echo: Hello World!"
Create a chat server that broadcasts messages to all connected clients:
Broadcast to AllJSON Objectchat{{$json.data}}HTTP Request → Process Data → WebSocket Response (Broadcast)
Send live updates to dashboard clients when data changes.
WebSocket Trigger → Database → WebSocket Response (Reply to Sender)
Receive data from IoT devices and send confirmation responses.
Schedule Trigger → Get Users → WebSocket Response (Send to Multiple)
Send scheduled notifications to specific connected users.
WebSocket Trigger → API Call → Transform Data → WebSocket Response
Stream processed data in real-time to connected applications.
| Setting | Description | Default |
|---|---|---|
| Port | Port number for the WebSocket server | 8080 |
| Path | URL path for WebSocket connections | /websocket |
| Bind Address | Network interface (0.0.0.0 for external, 127.0.0.1 for local) | 0.0.0.0 |
| Trigger On | When to trigger workflow (Connection/Message/Both) | Message |
| Response Mode | How to respond (None/Echo/Custom) | No Response |
| Operation | Description |
|---|---|
| Reply to Sender | Send message back to the original sender |
| Send to Specific Connection | Send to a specific connection ID |
| Broadcast to All | Send to all connected clients |
| Get Active Connections | Retrieve list of active connections |
const ws = new WebSocket('ws://your-server:8080/websocket');
ws.onopen = () => {
console.log('Connected to n8n WebSocket');
ws.send(JSON.stringify({
type: 'greeting',
message: 'Hello from browser!'
}));
};
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Received:', data);
};
ws.onclose = () => console.log('Disconnected');
ws.onerror = (error) => console.error('Error:', error);
import asyncio
import websockets
import json
async def websocket_client():
uri = "ws://your-server:8080/websocket"
async with websockets.connect(uri) as websocket:
# Send message
await websocket.send(json.dumps({
"type": "data",
"payload": {"temperature": 23.5, "humidity": 60}
}))
# Receive response
response = await websocket.recv()
print(f"Server response: {response}")
# Run the client
asyncio.run(websocket_client())
const WebSocket = require('ws');
const ws = new WebSocket('ws://your-server:8080/websocket');
ws.on('open', () => {
console.log('Connected to n8n');
// Send periodic data
setInterval(() => {
ws.send(JSON.stringify({
type: 'sensor_data',
data: {
timestamp: new Date().toISOString(),
value: Math.random() * 100
}
}));
}, 5000);
});
ws.on('message', (data) => {
console.log('Received:', data.toString());
});
# Install websocat for command-line WebSocket testing
# https://github.com/vi/websocat
# Connect and send message
echo '{"type": "test", "message": "Hello from command line"}' | websocat ws://localhost:8080/websocket
Use these variables in your messages:
| Variable | Description | Example |
|---|---|---|
{{timestamp}} | Current ISO timestamp | 2025-05-23T21:30:00.000Z |
{{date}} | Current date | 5/23/2025 |
{{time}} | Current time | 9:30:00 PM |
{{connectionCount}} | Number of active connections | 5 |
{{connectionId}} | Current connection ID | abc123 |
Example template:
{
"type": "notification",
"message": "Hello user!",
"timestamp": "{{timestamp}}",
"activeUsers": {{connectionCount}},
"yourConnectionId": "{{connectionId}}"
}
const ws = new WebSocket('ws://localhost:8080/websocket', {
headers: {
'Authorization': 'Bearer your-secret-token'
}
});
const ws = new WebSocket('ws://localhost:8080/websocket?token=your-secret-token');
Set maximum concurrent connections to prevent abuse:
{
"maxConnections": 100,
"pingInterval": 30000,
"messageSizeLimit": 1024
}
❌ "Connection refused"
❌ "Can't connect from external network"
0.0.0.0 (not 127.0.0.1)❌ "Authentication failed"
❌ "Message not sending"
Enable debug logging in n8n:
export N8N_LOG_LEVEL=debug
n8n start
{
"event": "message",
"data": "client message content",
"connectionInfo": {
"connectionId": "abc123",
"remoteAddress": "192.168.1.100",
"userAgent": "Mozilla/5.0...",
"timestamp": "2025-05-23T21:30:00.000Z"
},
"meta": {
"totalConnections": 5,
"messageSize": 1024,
"timestamp": "2025-05-23T21:30:00.000Z"
}
}
{
"operation": "replyToSender",
"connectionId": "abc123",
"message": "Hello World!",
"success": true,
"totalConnections": 5,
"timestamp": "2025-05-23T21:30:00.000Z"
}
git clone https://github.com/poewer/n8n-nodes-websocket.git
cd n8n-nodes-websocket
npm install
npm run build
# Build and link locally
npm run build
npm link
# In your n8n project
npm link n8n-nodes-websocket
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-featuregit commit -m 'Add amazing feature'git push origin feature/amazing-featureThis project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ for the n8n community
⭐ If this package helped you, please give it a star on GitHub!
FAQs
Enhanced WebSocket nodes for n8n with bidirectional communication support
The npm package n8n-nodes-websocket receives a total of 13 weekly downloads. As such, n8n-nodes-websocket popularity was classified as not popular.
We found that n8n-nodes-websocket demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.