Knowledge Hub

Factora Academy

Technology and architecture

MQTT explained

Topics, wildcards, quality of service, and the factory user.

Introduction

Who this is for. Integrators who will point Factora at a broker.

MQTT is publish and subscribe. A client connects to a broker, publishes a payload to a topic, and the broker copies it to every client that subscribed. The publisher does not need to know the subscribers. This article uses only the topics Factora and the network server already use.

Architecture

Three roles. Factora is a subscriber on the LoRaWAN broker.

One job for each part
  1. PublisherThe network server publishes each uplink event.
  2. BrokerCopies each payload to subscribers who are allowed to read that topic.
  3. SubscriberThe Factora worker receives the payload and stores a number.

Step 0. Read a topic

  1. A topic is a slash-separated path.
  2. Application uplinks use application/<application id>/device/<DevEUI>/event/up.
  3. The built-in broker, for devices that are not LoRaWAN, uses factora/<factory slug>/devices/<device code>/telemetry.
Topic field
Topic / node / register pattern is the topic box on the connector form.

Step 1. Use wildcards

  1. A plus sign is one level. application/7/device/+/event/up is every device in application 7.
  2. A hash is the rest of the topic. application/7/# is everything under that application, and only when the hash is the last level.
  3. A pattern without a wildcard must be the same length as the topic.
Screenshot — Coming soon. Wildcard rules are broker configuration, not a Factora screen.

Step 2. Choose a quality of service

  1. QoS 0 is at most once. Gateway traffic that never leaves the machine uses it.
  2. QoS 1 is at least once. Factora connectors default to QoS 1. A retry can deliver the same payload twice, so ingest ignores a duplicate message id when it has one.
  3. QoS 2 is exactly once. We do not use it.
  4. A retained message is the broker's last copy of a topic. Uplinks are live events, not retained configuration.
Screenshot — Coming soon. The connector form does not ask for a QoS. It sends QoS 1.

Step 3. Limit the factory user

  1. The factory user may read only application/<that factory's application id>/# and may not publish.
  2. Reconnect waits step through 5, 10, 30, and 60 seconds.
  3. Each connector keeps at most 250 messages in flight. Past that, the last error is backpressure. One connector failing does not stop the others.
Screenshot — Coming soon. Broker users and access lists are not edited in Factora.