MQTT Entry Point

This entry point accepts MQTT actions from an Air for Cellular device and forwards the action to an MQTT broker via MQTT or MQTTS. Both publish (from device to broker) and subscribe (receive messages from the broker) are supported.


Entry Point

Your device should be configured to publish or subscribe to topics on:



Publish Example

When publishing a message, our device output looks something like this:

mosquitto_pub -h -p 1883 -t mytopic -m message -d
>Client mosqpub/my-device sending CONNECT
>Client mosqpub/my-device received CONNACK
>Client mosqpub/my-device sending PUBLISH (d0, q0, r0, m1, 'mytopic', ... (7 bytes))
>Client mosqpub/my-device sending DISCONNECT

If we inspect the MQTT broker, we should see our message:

>1482290763: New connection from on port 8080.
>1482290763: New client connected from as mosqpub/my-device (c1, k60).
>1482290763: Sending CONNACK to mosqpub/my-device (0, 0)
>1482290767: Received PUBLISH from mosqpub/my-device (d0, q0, r0, m0, 'mytopic/295000012345678', ... (7 bytes))
>1482290767: Received DISCONNECT from mosqpub/my-device
>1482290767: Client mosqpub/my-device disconnected.

In this example, Append IMSI to topic is enabled. When our MQTT broker receives the publish message action, the topic has been updated to include the IMSI of our subscriber.

Subscribe Example

Subscribing to a topic works similarly. Here, we will use two subscribers, with one subscribing to an MQTT topic on our broker, and the other publishing a message on that topic.

On our subscribing device:

mosquitto_sub -h -p 1883 -t mytopic -d
>Client mosqsub/my-subscriber sending CONNECT
>Client mosqsub/my-subscriber received CONNACK
>Client mosqsub/my-subscriber sending SUBSCRIBE (Mid: 1, Topic: test, QoS: 0)
>Client mosqsub/my-subscriber received SUBACK
>Subscribed (mid: 1): 0

On our broker, we can confirm that our first device has subscribed:

>1482291094: New connection from on port 8080.
>1482291094: New client connected from as mosqsub/my-subscriber (c1, k60).
>1482291094: Sending CONNACK to mosqsub/my-subscriber (0, 0)
>1482291094: Received SUBSCRIBE from mosqsub/my-subscriber
>1482291094:     mytopic (QoS 0)
>1482291094: mosqsub/my-subscriber 0 mytopic
>1482291094: Sending SUBACK to mosqsub/my-subscriber

When we publish a message from our second device, our MQTT broker should report:

>1482291169: New connection from on port 8080.
>1482291169: New client connected from as mosqpub/my-publisher (c1, k60).
>1482291169: Sending CONNACK to mosqpub/my-publisher (0, 0)
>1482291169: Received PUBLISH from mosqpub/my-publisher (d0, q0, r0, m0, 'mytopic', ... (7 bytes))
>1482291169: Sending PUBLISH to mosqsub/my-subscriber (d0, q0, r0, m0, 'mytopic', ... (7 bytes))
>1482291169: Received DISCONNECT from mosqpub/my-publisher
>1482291169: Client mosqpub/my-publisher disconnected.

And on our first device, we will receive the published message:

>Client mosqsub/my-subscriber received PUBLISH (d0, q0, r0, m0, 'test', ... (7 bytes))

Advanced Configuration

The MQTT entry point can also be configured through the Soracom API or CLI by using the SoracomBeam namespace.

Configuration should be performed using mqtt:// as the configuration key value.



    "key": "mqtt://",
    "value": {
      "name": "AWS IoT",
      "destination": "mqtts://",
      "enabled": true,
      "addSubscriberHeader": false,
      "useClientCert": true,
      "clientCerts": {
        "default": {
          "key": "-----BEGIN RSA PRIVATE KEY-----\n...",
          "cert": "-----BEGIN CERTIFICATE-----\n...",
          "ca": "-----BEGIN CERTIFICATE-----\n..."