ApplicationExperienceEdge 1.0.0Embedded 1.0.0

MQTT Node

The MQTT Node allows a workflow to publish a message to the configured topic on the Losant MQTT Broker, the Gateway Edge Agent Broker, or an MQTT Integration.

MQTT Node

Node Properties

Regardless of workflow class, there are two required properties that must be set within the node:

  • Topic Template: Enter a string template for the topic on which to publish the message. This must render to a valid topic name, and depending on the selected broker, there may be additional rules around the topic’s format.
  • Message Template: Optionally, you may also enter a message to publish on the chosen topic. If no message is entered, or if the string template entered in this field does not resolve to a value, a blank message will be published on the specified topic.

Depending on the workflow class in which the node is being utilized, there are additional configuration options and validation rules.

Application & Experience Workflows

In Application Workflows and Experience Workflows, you must also choose the broker on which to publish your message …

  • Losant MQTT Broker: By default, the message will be published on Losant MQTT Broker. When choosing this option, there are additional rules for the custom topic on which you are attempting to publish your message.
  • MQTT Integration: Any MQTT Integrations you’ve created in your application are also options for where to publish the message.

    • You may enter any valid MQTT topic; it does not have to be a topic you configured for triggering workflows when setting up the integration.
    • If the integration is disabled, the node will throw an error.
    • If the integration is disconnected, the delivery will occasionally retry for up to one hour. Losant will queue a maximum of 1,000 messages per integration.

Edge Workflows

Usage of the MQTT Node in Edge Workflows also requires choosing the broker on which to publish the message …

Embedded Workflows

Embedded Workflows are a special case: They do not require choosing a broker on which to publish the message. Instead, when the node executes, the Embedded Edge Agent will invoke its eea_send_message method with the following arguments:

  1. Topic: The resolved value of the string template entered in the Topic Template field.
  2. Topic Length: The length, in bytes, of the Topic argument.
  3. Message: The resolved value of the string template entered in the Message Template field.
  4. Message Length: The length, in bytes, of the Message argument.
  5. QoS: The Quality of Service with which this message should be treated. The value is always 1.

It is up to the native code on the device to then send the message through to the Losant MQTT Broker.

Embedded Workflows also take an optional “Return Code Path”, which is a payload path at which the error code returned by eea_send_message will be placed. 0 is considered successful, and any non-0value is treated as an error. If a “Return Code Path” is not provided, and eea_message_received returns a non-0 value, the node will throw an error and execution of the workflow will stop.

Throttling And Limits

When sending messages to the Losant cloud broker, the MQTT Node has the same throttling and data size limit rules as messages published to the broker directly.

  • The node is limited to 30 calls in a 15-second window (per topic) — on average, 2 calls per second.
  • Additionally, MQTT Node allows for sending a maximum message size of 256KB to the Losant cloud broker.

Was this page helpful?


Still looking for help? You can also search the Losant Forums or submit your question there.