Overview
This node acts as a trigger to listen to WebSocket events from ComfyUI, a user interface system. It connects to a ComfyUI WebSocket server and listens for specific event types, either predefined or custom, and emits these events as workflow triggers. It supports automatic reconnection with configurable retry limits and intervals, and includes a heartbeat mechanism to keep the WebSocket connection alive. This node is useful for workflows that need to react in real-time to ComfyUI events such as workflow execution starts, status updates, or any custom event defined by the user.
Use Case Examples
- Trigger a workflow when a ComfyUI workflow execution starts by selecting the predefined event 'ky_monitor.queue'.
- Listen to all ComfyUI events by selecting the 'All Events' predefined event type.
- Trigger a workflow on a custom event by specifying a custom event type string.
Properties
| Name | Meaning |
|---|---|
| Event Type Selection Method | Choose whether to use predefined event types or custom event types to listen for. |
| Predefined Event Type | Select a predefined ComfyUI event type to listen to, such as 'ky_monitor.queue' for workflow execution start, 'status' for status updates, or 'all' for all events. Only shown if 'Predefined Events' is selected. |
| Custom Event Type | Enter a custom event type string to listen to. Only shown if 'Custom Events' is selected. |
| Reconnection Interval (seconds) | Number of seconds to wait before attempting to reconnect after a disconnection. |
| Maximum Retry Count | Maximum number of reconnection attempts. A value of -1 means unlimited retries. |
| Instance ID | Optional identifier for the trigger instance, appended to output results. |
| Enable Heartbeat Keep-Alive | Enable or disable the heartbeat mechanism to keep the WebSocket connection active and prevent timeouts. |
| Heartbeat Interval (seconds) | Interval in seconds for sending heartbeat ping messages to keep the connection alive. Only shown if heartbeat is enabled. |
Output
JSON
event- The type of the event received from ComfyUI.data- The data payload associated with the event.timestamp- ISO timestamp when the event was received.instance_id- Optional instance ID specified in the node configuration, appended to the output.original_url- The WebSocket server URL from which the event was received.
Dependencies
- WebSocket library (ws)
- Crypto library for UUID generation
Troubleshooting
- WebSocket connection errors may occur if the API URL is invalid or unreachable. Verify the URL and network connectivity.
- If authentication fails, ensure the API key is correctly configured and valid.
- If the node stops reconnecting, check the maximum retry count setting; -1 allows unlimited retries.
- Heartbeat failures may cause connection timeouts; ensure the heartbeat interval is appropriate and the server supports ping/pong messages.
Links
- WebSocket API Documentation - General information about WebSocket connections used by the node.
- Node.js Crypto randomUUID - Used for generating unique client IDs for WebSocket connections.