Actions2
- Message Actions
- Connection Actions
Message → Send Message
AI-generatedOverview
This node enables interaction with WebSocket streams within an n8n workflow. Specifically, it supports sending messages over an existing WebSocket connection or closing a WebSocket connection. It is useful in scenarios where real-time communication is required, such as pushing updates to a live dashboard, sending commands to a WebSocket server, or gracefully terminating WebSocket connections.
For example, after receiving a WebSocket connection from a trigger node, this node can send JSON-formatted messages through that connection to notify other systems or clients. Alternatively, it can close the connection when no longer needed.
Properties
| Name | Meaning |
|---|---|
| Websocket Resource Field (Parameter Name) | The name of the field in the incoming data that holds the WebSocket resource object. This must match the field set by the WebSocket trigger node. |
| Message | The JSON message object to send over the WebSocket connection. |
Output
The node outputs an array of JSON objects, each representing the result of processing one input item. Each output item contains:
success: A boolean indicating whether the operation succeeded (true).- A property named after the WebSocket resource field (e.g.,
"ws"), containing the WebSocket resource object used for sending or closing.
No binary data is output by this node.
Dependencies
- Requires an active WebSocket resource object passed into the node via the specified WebSocket resource field. This resource is typically provided by a preceding WebSocket trigger node.
- No external API keys or credentials are required by this node itself, but the WebSocket connection must be established and managed elsewhere in the workflow.
Troubleshooting
Error: "Execution error: No websocket resource received"
This occurs if the specified WebSocket resource field is missing from the input data. Ensure that the field name matches exactly the one set by the WebSocket trigger node and that the trigger node is correctly configured and connected.Message not sent or connection not closed
Verify that the WebSocket resource is valid and active. If the connection has been closed or lost before this node executes, sending or closing operations will fail silently or throw errors.Incorrect WebSocket resource field name
Double-check the "Websocket Resource Field (Parameter Name)" property to ensure it matches the field name carrying the WebSocket object.Handling failures
If "Continue On Fail" is enabled, errors will be captured in the output JSON under anerrorproperty instead of stopping execution.
Links and References
- WebSocket API MDN Documentation
- n8n WebSocket Trigger Node Documentation (for setting up WebSocket resources)