Overview
This node acts as a trigger that listens to WebSocket events emitted by a ComfyUI server. It establishes a WebSocket connection to the specified ComfyUI server URL and listens for specific event types, either predefined or custom. When an event matching the selected type is received, the node outputs the event data, allowing subsequent workflow steps to react to real-time updates from ComfyUI.
Common scenarios where this node is beneficial include:
- Monitoring the start of workflows in ComfyUI to trigger downstream automation.
- Reacting to status updates or other runtime events from ComfyUI.
- Listening to all events for comprehensive logging or analytics.
- Integrating ComfyUI event streams into broader automation pipelines.
Practical example:
- Automatically save generated images or metadata when a ComfyUI workflow completes by listening to the
ky_monitor.queueevent. - Trigger notifications or update dashboards based on status changes in ComfyUI workflows.
Properties
| Name | Meaning |
|---|---|
| ComfyUI 服务器地址 | The WebSocket URL of the ComfyUI server to connect to (e.g., ws://localhost:8188 or wss://example.com). Do not include the /ws path. |
| 手动指定 Header Key | Optional: Manually specify the HTTP header key used for authentication (e.g., Authorization). If provided, this overrides the header key from credentials. |
| 手动指定 Header Value | Optional: Manually specify the HTTP header value used for authentication. If provided, this overrides the header value from credentials. |
| 事件类型选择方式 | Choose whether to listen to a predefined event type or a custom event type. Options: 预定义事件 (predefined), 自定义事件 (custom). |
| 预定义事件类型 | Select one of the predefined ComfyUI event types to listen for: - ky_monitor (ky_monitor.queue): triggered when a workflow starts execution.- 状态更新 (status): triggered on status updates.- 所有事件 (all): listen to all event types. |
| 自定义事件类型 | Specify a custom event type string to listen for (e.g., custom.event). Only shown if "自定义事件" is selected above. |
| 重连间隔 (秒) | Number of seconds to wait before attempting to reconnect after a disconnection occurs. Default is 5 seconds. |
| 最大重试次数 | Maximum number of reconnection attempts. -1 means unlimited retries. Default is -1. |
| 实例 ID | Optional: An identifier string for this trigger instance. This ID will be attached to each output event for tracking purposes. |
| 启用心跳保活 | Enable a heartbeat mechanism that periodically sends ping messages to keep the WebSocket connection alive and prevent timeouts. Default is enabled (true). |
| 心跳间隔 (秒) | Interval in seconds between heartbeat ping messages. Only applicable if heartbeat is enabled. Default is 30 seconds. |
Output
The node outputs data whenever a matching WebSocket event is received from the ComfyUI server. Each output item contains:
event: The event type string received.data: The payload data associated with the event.timestamp: ISO 8601 timestamp indicating when the event was processed.instance_id: The optional instance ID specified in the node properties.original_url: The ComfyUI server URL connected to.
The output is structured as JSON objects within the main output stream.
This node does not output binary data.
Dependencies
- Requires a running ComfyUI server exposing a WebSocket endpoint (default path
/wsappended internally). - Optionally requires an API authentication token or header configured either via manual header inputs or stored credentials.
- Uses the WebSocket protocol (
ws://orwss://) to connect. - No additional external services are required beyond the ComfyUI WebSocket server.
Troubleshooting
- WebSocket connection errors: Ensure the ComfyUI server URL is correct and reachable. Verify network connectivity and that the WebSocket endpoint is active.
- Authentication failures: If using authentication headers, confirm the header key and value are correctly set either manually or via credentials.
- No events received: Check that the selected event type matches those emitted by your ComfyUI server. Use the "所有事件" option to listen to all events for debugging.
- Connection drops and reconnections: The node automatically attempts to reconnect based on configured retry limits and intervals. If reconnection fails repeatedly, verify server stability and network conditions.
- Heartbeat failures: If the connection times out, try enabling heartbeat and adjusting the interval to maintain the connection.
Common error messages:
"ComfyUI 服务器地址未配置": The server URL property is missing or empty; provide a valid WebSocket URL."WebSocket 错误": Indicates a low-level WebSocket error; check server availability and credentials."达到最大重试次数,停止重连": The node has reached the maximum reconnection attempts; increase the retry count or fix underlying connectivity issues.
Links and References
- ComfyUI GitHub Repository — For details on ComfyUI and its WebSocket events.
- WebSocket Protocol RFC 6455 — Technical specification of WebSocket.
- n8n Documentation on Creating Custom Nodes