Skip to content

MQTT Messaging

The MQTT messaging protocol is a lightweight publish/subscribe messaging transport that is ideal for connecting remote devices with a small code footprint and minimal network bandwidth to the cloud.

MQTT is used by Ioto for general device communications and for transporting the device state to the cloud.

Configuring

As devices are provisioned by the Builder into a Device Cloud, the Ioto service will create and distribute the necessary device X.509 certificates, keys and resources to configure secure cloud communications over MQTT.

The device-specific certificates and keys are provided to the Ioto device agent as part of the device provisioning, registration/claiming process. The device agent will save these on the device.

Ioto Key/Value Store

Many devices require simple device settings that can be managed by the cloud. In addition to the general Ioto device database, Ioto provides provides a simple key/value store in the device database called the Store. This key/value store is ideal for a small set of simple device settings. If you have more elaborate device settings and state, they are best stored directly in the device database.

Values can easily be written and read to/from the Store using the device agent ioSet APIs.

iotSet("model", "Acme Rocket");
iotSetNum("cpu", 55);

These values can be displayed in the Device Manager UI and can be retrieved in the device via the ioGet APIs.

char *model = iotSet("model");
int64 cpu = iotSetNum("cpu");

These APIs are simple wrappers over the mqttPublish and mqttRequest APIs.

Ioto Device Agent

The Ioto device agent provides an efficient MQTT client that is ideal for connecting to the cloud. It supports:

  • MQTT 3.1.1
  • Connect, publish, subscribe, ping and disconnect messages.
  • TLS encryption with ALPN over port 443 to get through firewalls.
  • Message quality of service for reliable delivery.
  • Retained messages.
  • High message throughput with exceptionally low overhead.
  • Wait for delivery or acknowledgement options.
  • Resilient reconnect on network interruptions.
  • Automatic configuration after cloud provisioning.
  • Parallelism via fiber coroutines. No ugly callbacks or complex threads.
  • Tiny footprint of 8K code.

See the Ioto MQTT Documentation for details about the Ioto Agent MQTT API with examples.

MQTT Reconnecting

The Ioto service will reliably maintain an MQTT connection to devices. If the network connection fails, Ioto will automatically reconnect to the cloud service.

Throttling

Ioto defines data limits to protect you, your devices, customers and the service. If a device or devices send too much data to the cloud, Ioto protects you and your customers by throttling (slowing) incoming data from offending devices.

Data Traffic

The amount of data you send to the device cloud is measured as the number of KBytes sent on average per device per hour. This traffic is then compared with the limit for your device cloud.

As you connect more devices, your data limit scales automatically with the number of devices connecting to the cloud. What is measured is the average data traffic over your entire pool of connecting devices.

For example, if you have 100 devices and a limit of 60 messages per device per hour, this means that your pool of devices can send up to 6,000 messages to the cloud per hour.

Ioto supports short-term burst traffic above the limit, but if your sustained, aggregate traffic exceeds your limit, the offending devices will have their sending rate throttled.

Throttling

When devices in a cloud cloud exceed the data limit, the offending devices will receive a throttle message and the device's Ioto agent will automatically slow down the rate of sending to the cloud.

Upon receiving a throttle message, Ioto will implement an exponential backoff strategy and will slow down the rate of sending. Messages can still be received and Ioto will be fully functional. However, the rate of sending will be reduced until the throttled condition is alleviated. This protects your account and your customer's quality of service. It also protects you against rogue devices that have been compromised.

If a device continues to exceed the limit for a device cloud, the device will be disconnected (released) from the device cloud and its communication certificates will be revoked. The device will then need to be reclaimed to join the device cloud.

Ioto measures your device traffic rate every 30 seconds and will throttle a device that is exceeding your traffic limit over a 1 minute period.

Please see Device Cloud Limits for limit details.

Terms

Please see the Terms of Use for acceptable use terms.