update websocket_nodes.md

This commit is contained in:
Tianzi Hou
2025-04-27 21:06:48 +01:00
parent 57e1c1b776
commit 124f605a54
+88 -2
View File
@@ -40,6 +40,36 @@
---
### Node: `WebSocket Server @ vrch.ai` (vrch.ai/viewer/websocket)
1. **Add the `WebSocket Server @ vrch.ai` node to your ComfyUI workflow.**
2. **Configure the Node:**
- **Server:**
- **`server`**: Enter the server's address and port in the format `IP:PORT`. The default is typically your local IP address and port **8001** (e.g., **`127.0.0.1:8001`**).
- **Debug Mode:**
- **`debug`**: Enable this option to print detailed debug information to the console for troubleshooting.
3. **Server Status Indicator:**
- The node displays a status indicator that shows whether the server is running:
- **Grey "Stopped"**: The WebSocket server is not running
- **Green "Running"**: The WebSocket server is active and accepting connections
4. **Usage:**
- This node must be executed in your workflow to start the WebSocket server
- Once running, it handles communication for all WebSocket nodes (Image and JSON)
- The server maintains separate connection paths for different data types (/image and /json)
- Multiple clients can connect simultaneously to the same server
**Notes:**
- This node is required for any WebSocket-based communication in your workflow.
- Only one server can run on a specific IP:port combination.
- If a server is already running on the specified address and port, the node will use the existing server.
- WebSocket connections are maintained even when your workflow is not actively running.
- When debug mode is enabled, the server outputs detailed connection logs to the console.
---
### Node: `IMAGE WebSocket Channel Loader @ vrch.ai` (vrch.ai/viewer/websocket)
1. **Add the `IMAGE WebSocket Channel Loader @ vrch.ai` node to your ComfyUI workflow.**
@@ -49,13 +79,15 @@
- **`channel`**: Select a channel number from **"1"** to **"8"** (default is **"1"**) to specify which WebSocket channel to listen on.
- **Server:**
- **`server`**: Enter the server's domain or IP address along with its port in the format `IP:PORT`. The default typically uses your IP and port **8001** (e.g., **`127.0.0.1:8001`**).
- **Placeholder:**
- **`placeholder`**: Choose the color of the placeholder image to display when no image data is received. Options are **"black"**, **"white"**, or **"grey"** (default is **"black"**).
- **Debug Mode:**
- **`debug`**: Enable this option to print detailed debug information to the console for troubleshooting.
3. **Receiving Images:**
- This node automatically connects to the specified WebSocket channel and listens for incoming image data.
- When an image is received, it will be processed and made available as an output that can be connected to other nodes in your workflow.
- If no image has been received yet, a black placeholder image will be provided.
- If no image has been received yet, a placeholder image with the selected color will be provided.
**Notes:**
- This node is designed to work with the `IMAGE WebSocket Web Viewer @ vrch.ai` node, receiving the images it broadcasts.
@@ -63,4 +95,58 @@
- The node continuously monitors for new images, allowing your workflow to react to images sent from any source that connects to the same WebSocket channel.
- When debug mode is enabled, the node outputs detailed logs to the console, which can help you track the image reception process and troubleshoot any issues.
---
---
### Node: `JSON WebSocket Sender @ vrch.ai` (vrch.ai/viewer/websocket)
1. **Add the `JSON WebSocket Sender @ vrch.ai` node to your ComfyUI workflow.**
2. **Configure the Node:**
- **JSON Input:**
- **`json_string`**: Enter the JSON string you want to send over WebSocket. This should be a properly formatted JSON string.
- **Channel:**
- **`channel`**: Select a channel number from **"1"** to **"8"** (default is **"1"**) to differentiate WebSocket connections.
- **Server:**
- **`server`**: Enter the server's domain or IP address along with its port in the format `IP:PORT`. The default typically uses your IP and port **8001** (e.g., **`127.0.0.1:8001`**).
- **Debug Mode:**
- **`debug`**: Enable this option to print detailed debug information to the console for troubleshooting.
3. **Sending JSON Data:**
- The node validates the JSON string before sending. If the string is not valid JSON, the node will raise a ValueError.
- Once validated, the JSON data is sent to the specified WebSocket channel and path (/json).
- The validated JSON is also available as an output that can be connected to other nodes.
**Notes:**
- This node works with the `WebSocket Server @ vrch.ai` node, which must be running to establish connections.
- Ensure your JSON string is properly formatted to avoid validation errors.
- The JSON data is sent through the WebSocket as a raw string.
- When debug mode is enabled, the node outputs detailed logs to the console, including the content of the sent JSON data.
---
### Node: `JSON WebSocket Channel Loader @ vrch.ai` (vrch.ai/viewer/websocket)
1. **Add the `JSON WebSocket Channel Loader @ vrch.ai` node to your ComfyUI workflow.**
2. **Configure the Node:**
- **Channel:**
- **`channel`**: Select a channel number from **"1"** to **"8"** (default is **"1"**) to specify which WebSocket channel to listen on.
- **Server:**
- **`server`**: Enter the server's domain or IP address along with its port in the format `IP:PORT`. The default typically uses your IP and port **8001** (e.g., **`127.0.0.1:8001`**).
- **Debug Mode:**
- **`debug`**: Enable this option to print detailed debug information to the console for troubleshooting.
- **Default JSON:**
- **`default_json_string`**: (Optional) Enter a default JSON string to use when no data is received. This should be a properly formatted JSON string.
3. **Receiving JSON Data:**
- This node automatically connects to the specified WebSocket channel and listens for incoming JSON data.
- When JSON data is received, it will be parsed and made available as an output that can be connected to other nodes in your workflow.
- If no JSON data has been received yet, the default JSON string will be used (if provided), otherwise an empty object `{}` is returned.
- If the provided default JSON string is not valid JSON, the node will raise a ValueError.
**Notes:**
- This node is designed to work with the `JSON WebSocket Sender @ vrch.ai` node, receiving the JSON data it broadcasts.
- The node automatically establishes and maintains WebSocket connections, reconnecting if the connection is lost.
- The node continuously monitors for new JSON data, allowing your workflow to react to data sent from any source that connects to the same WebSocket channel.
- When debug mode is enabled, the node outputs detailed logs to the console, which can help you track the JSON data reception process.