Acly / comfyui-tooling-nodes

Nodes for using ComfyUI as a backend for external tools. Send and receive images directly without filesystem upload/download.
GNU General Public License v3.0
319 stars 38 forks source link

Sockets node not receiving data image #8

Closed albseb511 closed 1 month ago

albseb511 commented 11 months ago

Hi i have setup node


const ws = new WebSocket('https://example.app/ws?clientId=b7f1429fac8bd2593e8');

ws.onopen = () => {
    console.log("Connected to server")
}
ws.onerror = (error) => {
    console.log(`Error:`, error)
}   
ws.onmessage = (e) => {
    console.log(e.data)
}

I am receiving updates

Connected to server
{"type": "status", "data": {"status": {"exec_info": {"queue_remaining": 0}}, "sid": "56da1da0b7f1429fac8bd2593e83f703"}}
{"type": "status", "data": {"status": {"exec_info": {"queue_remaining": 1}}}}
{"type": "status", "data": {"status": {"exec_info": {"queue_remaining": 1}}}}
{"type": "status", "data": {"status": {"exec_info": {"queue_remaining": 0}}}}

I am not able to get the images data here, how do i get it?

how i am doing it is, i have a frontend -> hits my backend -> connects on ws, and makes the prompts apis for comfynodes.

response from api

{
  prompt_id: 'b2c65b71-02ff-4c62-ae13-70bcdf08f919',
  number: 11,
  node_errors: {}
}

can you help me with documentation here?

albseb511 commented 11 months ago

Okay i seem to have got it working

  1. client_id has to be setup on WS, which i had done, but the same client id, needs to be also setup while making a prompt. i did not do that.
    {
            prompt: json,
            client_id: client_id
    }

for websockets

/ws?clientId='+client_id

Check the link here https://github.com/comfyanonymous/ComfyUI/blob/master/script_examples/websockets_api_example.py

ionflow commented 10 months ago

@albseb511 what else did you have to do to get this to work? I'm running the default ComfyUI locally with the Save Image (Websocket) node at the end of my workflow. In Postman I get a connection to the ComfyUI websocket (ws://127.0.0.1:8188/ws?clientId=ebd88b88-7e30-4322-bf10-762f8e18a40e). This is the response I get:

{"type": "status", "data": {"status": {"exec_info": {"queue_remaining": 0}}, "sid": "ebd88b88-7e30-4322-bf10-762f8e18a40e"}}

but when I send the prompt in the format you have above with this client_id I never get a message response. Wondering if I'm missing a step.