subscribe websocket on backend

This block is part of the websocket group and was last modified in core v13.0.5.

subscribe websocket on backend v13.0.5

Subscribes the websocket to a specific channel. All broadcasts will be handled in the backend.

In pins 4 + flow
  • flow
    flow
  • channels required
    array

    Multiple channels you would like the server to subscribe / listen on • Hidden when other fields are filled

  • channel required
    value

    A channel you would like the server to subscribe / listen on • Hidden when other fields are filled

  • events
    array

    Listen on the provided events. If you would like to listen on all events within this channel, leave this array empty or provide * as one of the values.

    Default ["*"]

  • skip jwt required
    condition

    Skips the broadcast of subscriptions to the frontend. If set to true, the frontend will not be able to resubscribe on the channels where the broadcast was skipped.

    Default false

Out pins 4 + flow
  • flow
    flow
  • on broadcast
    execute_function

    The callback function requested whenever we received any event on any of the given channels

  • success
    condition

    Indicates if we could start subscribing at all, true could indicate we subscribed to one of the many given channels.

  • error
    value
  • channels
    array

    Channels we succesfully subcribed to

Subscribes the current websocket connection to the given channels (the channels array, or the single channel value) and runs the function wired to on_broadcast for each incoming broadcast, passing its event and message. success=true only means the block ran with a callback and a websocket : it stays true even when ZERO channel subscriptions succeeded, so check the channels output for what actually subscribed. An empty channel list fails with MISSING_CHANNELS, no wired callback with MISSING_CALLBACK, no active websocket with MISSING_WEBSOCKET; in simulation it does nothing and errors PRODUCTION_RUN_ONLY. An empty events array listens to all events on the channel; skipjwt=true hides the subscription from the frontend.

A typical wiring for subscribe websocket on backend: a function trigger starts the flow; the function out pin wires to an execute block.

Studio canvas example for the subscribe websocket on backend block: typical wiring for subscribe websocket on backend.

Version history

Introduced in v13.0.5.


Back to websocket Return to the main group to view all sub-groups Back to websocket Return to the group to view all blocks within this group