Nodes/comfyui-tensorop/SendImageOnWebSocket
ComfyUI Node

SendImageOnWebSocket

Stream generated images over ComfyUI's websocket — no files, no database

By un-seen·Created 2 years ago·Updated 2 years ago· 46
SendImageOnWebSocket
  • images
    event

    Most of ComfyUI's save nodes write files. SendImageOnWebSocket doesn't write anything - it pushes the image straight over ComfyUI's own websocket to whoever is listening, tagged with a label you choose. If you're building a custom frontend that should react the moment a generation finishes, or you want previews out of the box and into a UI without touching disk, this is the node. It's also the only node in the comfyui-tensorops pack that works with zero external setup - no Redis, no S3, no SurrealDB to stand up first.

    How it works

    Under the hood it reuses the exact binary channel ComfyUI itself uses for in-UI previews. For each image in the incoming batch, it converts the tensor to a PIL image and calls:

    server.send_sync(
        BinaryEventTypes.UNENCODED_PREVIEW_IMAGE,
        ["PNG", image, event],
        server.client_id,
    )
    

    That's PromptServer.instance, ComfyUI's own server object, sending a PNG-encoded preview over the websocket that the connected frontend already has open. The event string rides along in the payload, so a listener can tell "this is a preview" from "this is the final result" by filtering on your label.

    One thing to be clear about: this goes to the ComfyUI client that queued the prompt - it's not a broadcast to the world, and it speaks ComfyUI's protocol, not a generic message bus. If you're just using the stock web UI, you'll mostly see it arrive like any preview message. The value shows up when you write a client that connects to ws://127.0.0.1:8188/ws and reacts to messages whose label matches your event.

    The inputs

    • event - a STRING label you invent ("final", "face", whatever), used as the discriminator in the message payload. Keep it stable; clients filter on it.
    • images - the IMAGE (or batch of images) to stream.

    No outputs - it's an output node. A batch of N images becomes N messages, all carrying the same event label, so your client should handle repeats.

    Install and config

    The repo has no real README, so it's the standard two ways. In ComfyUI Manager, search the pack title comfyui-tensorop, or by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/un-seen/comfyui-tensorops
    

    then restart ComfyUI. A quick honesty note: this pack is a single commit from October 2024, and its one moment of community fame was ComfyUI Manager warning about node-name conflicts with Kijai's Florence2 pack - Kijai's read being that node names had been copied in. MIT-licensed and silent since. If you only need the websocket node, it's the cheapest node in the pack to try, but skim the source regardless; custom nodes run with full user permissions and this one has no review history.

    Gotchas

    • No database or config needed - this is the rare node in this pack where you don't touch nodes/config.py at all. If you want a feel for how the pack wires things without standing up infrastructure, start here.
    • The target is the client that queued the prompt. A separate app that connects on its own won't get these messages automatically; it has to be the same client session. Plan your frontend accordingly.
    • It's PNG over the preview channel. That means it's fine for near-real-time streaming, but if you also need durable storage, pair it with a save node - websocket messages are gone if nobody's listening.
    • Your label is a convention, not a guarantee. Nothing validates it, and nothing stops two event names from colliding in a busy client. Namespace them if you're streaming more than one kind of message.

    The pack ships a sibling, SendJsonOnWebSocket, for pushing JSON the same way - same event-label trick, same protocol. Together they're the "stream results out of ComfyUI" pair, and this image one is the half people usually want first.

    Categorytensorops

    Inputs (2)

    NameTypeDefaultDescription
    eventSTRING
    imagesIMAGE

    Outputs (0)

    No outputs