DocsNodesDoes somethingSend to client

Send to client

Sends a command to one client, like switching a relay on. If the client is offline the command waits for it. Turn on Wait for confirmation and the step leaves by what became of the command.

Kindaction:clientMessage
GroupDoes something
Credits1 credit
Ports out1 or 3

How it looks

With Wait for confirmation on, the step has three ways out instead of default, and each can lead somewhere different.

Settings

SettingRequiredWhat it does
ClientYesThe client to send to. Pick one, or use a value from the run such as trigger.clientRefId to answer whoever started it.
Command typeYesThe command name, like relay.set. 1–100 characters. Can't start with sys. or be capabilities or state.report.
PayloadNoAny JSON, up to 64 KB. Values from the run can be placed in it.
Wait for confirmationNoOff by default. When on, the step waits for the client's sys.ack and leaves by acked, failed or timeout.
TimeoutNoHow long to wait for the confirmation. 30 seconds when unset, at most the command's 24-hour lifetime. The command expires when the step stops waiting.

Ports

PortWhen
defaultWait for confirmation is off. The run moves on as soon as the command is queued.
ackedThe client confirmed it received the command. This is delivery, not success: report the outcome as a reading if it matters.
failedThe client refused it, for example because it arrived after expiresAt.
timeoutNo confirmation arrived in time. The command expires, so the client won't act on it later.

What it adds to the run

ValueHolds
commandWith Wait for confirmation on: what became of the command, so a later node can tell acked from timeout.

On the board

The SDKs confirm delivery for you. Check for the command type in your message handler; it runs when the command arrives.

wbskt.onMessage([](const WbsktMessage& message) {
  if (strcmp(message.type, "relay.set") == 0) {
    bool on = message.payload["on"] | false;
    digitalWrite(PUMP_PIN, on ? HIGH : LOW);
  }
});
wbskt.OnMessageReceived += (type, payload, commandId) =>
{
    if (type == "relay.set")
        pump.Switch(payload);
};
def handle(message):
    if message.type == "relay.set":
        pump.value = message.payload["on"]

client.on_message = handle
If the board is offlineThe command waits on the server for up to 24 hours and arrives, oldest first, when the board reconnects. With Wait for confirmation on, the step's timeout still applies.

Problems you might see

CodeMeans
CLIENT_MESSAGE_NO_TARGETClient filled in to something that isn't a client reference.
CLIENT_MESSAGE_INVALIDThe command type is missing or reserved, or the payload is too large. Shown when you publish.
CLIENT_MESSAGE_ACK_TIMEOUTThe timeout is out of range. Shown when you publish.
COMMAND_PUBLISH_ERRORThe command couldn't be queued. Retryable.

Sending a command from the API instead has its own codes, like COMMAND_TYPE_RESERVED and CLIENT_INACTIVE, on the error codes page.