WebSocket Output
Send data over a WebSocket connection.
What it does
WebSocket Output sends the value wired into Message out over a live WebSocket connection. In Server mode it broadcasts to every client that connects to it. In Client mode it connects out to an external WebSocket server at a URL you set. Either mode reports whether a client is connected, whether the last message went out, and any error text.
Send On Change is on by default, so a static value does not resend every frame.
When to use it
Live values (numbers, text, JSON-shaped strings) pushed from the graph to a browser page, a custom app, or another tool over WebSocket
The graph acting as a WebSocket server that other software connects into
The graph acting as a client, pushing updates into an existing WebSocket server elsewhere on the network
Traffic throttled so only real changes to the message are sent
| Parameter | Type | Default |
|---|---|---|
message | Any | — |
mode | String | "server" |
url | String | "" |
send_on_change | Boolean | true |
enabled | Boolean | true |
Gotchas
Mode decides whether URL is read. In Server mode the URL input is ignored and the node listens for incoming connections. It takes effect only in Client mode, as the address to connect out to, for example
ws://localhost:8080.With Enabled off the node reports no connection and sends nothing. It stays in the graph doing no work rather than being bypassed, so check this toggle first when a downstream client goes quiet.
Turn Send On Change off to send on every cook even when the value has not changed, for example to keep a heartbeat alive.
Worked example
Add a WebSocket Output node and wire a value into Message.
Leave Mode on Server to broadcast to any client that connects, or switch to Client and enter a URL to push into an existing WebSocket server.
Watch the Connected output to confirm a client is attached, and Sent to see when a message goes out.
If nothing reaches the other end, check the Error output.
See also
WebSocket Input · OSC Output · MQTT Publish · Numbers, signals & audio