WebSocket Response

Send response to a WebSocket client

Overview

This node sends a response message to a WebSocket client connected to a specified WebSocket server. It is useful in workflows where you want to communicate back to clients over WebSocket connections, for example:

  • Sending real-time updates or acknowledgments to a specific client after processing some data.
  • Broadcasting messages to all clients connected to a WebSocket server.
  • Responding dynamically based on input data or context about which client or server to target.

Practical examples include notifying a web app user of the status of a background job, pushing live data updates to dashboards, or sending alerts to multiple connected clients simultaneously.

Properties

Name Meaning
Connection ID Method Where to get the WebSocket server ID from. Options: Use Server ID from Input, Custom Server ID, Use Context Server.
Custom Server ID Custom WebSocket server ID to use (format: ws-{identifier}). Shown if "Custom Server ID" method selected.
Server ID Property Property name in the input JSON that contains the server ID. Used if "Use Server ID from Input" method selected.
Client ID Method Where to get the client ID to send the response to. Options: Use Client ID from Input, Custom Client ID, Broadcast to All Clients.
Client ID Property Property name in the input JSON that contains the client ID. Used if "Use Client ID from Input" method selected.
Custom Client ID Custom client ID to send the response to. Shown if "Custom Client ID" method selected.
JSON Response Whether the response should be formatted as JSON (true) or sent as plain text (false).
Response Data The response string to send when JSON Response is false. Can contain expressions.
Response JSON The JSON object to send when JSON Response is true. Can contain expressions.

Output

The node outputs an array of JSON objects, one per input item processed. Each output JSON includes:

  • All original input JSON properties.
  • success: boolean indicating if the message was successfully sent.
  • serverId: the WebSocket server ID used.
  • clientId: the client ID targeted, or "broadcast" if sent to all clients.
  • serverInfo: optional additional info about the server from execution context if available.
  • error: present only if sending failed, containing the error message.

No binary data is output by this node.

Dependencies

  • Requires an active WebSocket server registered in the global execution context or identified via input/custom/context.
  • Uses a WebSocket registry singleton to manage servers and clients.
  • Depends on a WebSocket client connection being open to send messages.
  • No external API keys or credentials are required by this node itself, but the WebSocket servers it connects to may require authentication configured elsewhere.

Troubleshooting

  • Error: "No active WebSocket servers found in execution context"
    Occurs if "Use Context Server" is selected but no active servers exist. Ensure at least one WebSocket server is running and registered.

  • Error: "WebSocket server with ID ... not found"
    Happens if the specified server ID does not match any registered server. Verify the server ID is correct and the server is active.

  • Error: "Client with ID ... not found on server ..."
    Indicates the target client ID is not connected to the specified server. Check the client ID property or custom client ID value.

  • Error: "WebSocket not open (state: ...)"
    Means the WebSocket connection to the client is not open when trying to send. This node retries sending up to 3 times with delays; if still failing, the error is thrown. Ensure clients remain connected.

  • Message not received by client
    Confirm the client is listening and able to receive messages. Also verify the message format matches client expectations (JSON vs plain text).

Links and References

Discussion