# Devices and IoT: governed MQTT

> MQTT devices and Sparkplug B nodes governed like an API: identity, their tenant's topics, slowed never cut, failover.

Concept - Since version 1.7.0 - Flexway v1.7.1 - https://flexway.io/en/docs/product-iot-devices/

> Product guide: what the feature brings, for whom, its limits and the version that delivered it - no configuration syntax.

| | |
| --- | --- |
| **What it does** | Sensors, controllers and plant gateways connect to the gateway in **MQTT 5 or 3.1.1** (TLS, WebSocket), in front of **your** broker (Mosquitto, EMQX, HiveMQ...). Each device is identified - certificate, API key or token -, each `PUBLISH` and subscription is judged against your AsyncAPI contract like an HTTP request: a device's topic is that of **its** tenant and **its** identity, never another's. **Sparkplug B 3.0**: plant edge nodes, their devices and each tenant's host application inside **its** group, commands under scopes, nodes online and offline tracked across every replica; **OPC UA PubSub** in JSON under an ordinary contract. The console's **Devices** screen shows connections, refusals, quotas and nodes, with five built-in alert rules |
| **Why it matters** | A device and an API under the same decision, audit and signals; a site, a customer, a tenant isolated from the others without ACLs hand-written in the broker; the broker's credentials stay the gateway's; a device whose key or certificate is withdrawn is cut at the next reload, even one that only listens; no other gateway on the market governs an MQTT entry for devices under a contract |
| **Use cases** | Open a shared broker to several sites or customers; connect a fleet of sensors with a certificate per device, the topic taken from the certificate; slow down a chatty device without cutting it; stop or redeploy the gateway keeping the devices' sessions (failover to another replica; their wills too, for an MQTT 5 device that declares a will delay); share a Sparkplug broker between several sites, each with its SCADA; be alerted of an offline node without mistaking a gateway failover for a plant failure |
| **Limits** | Tested against Mosquitto, EMQX (one node) and HiveMQ CE; the gateway relays, it stores nothing: sessions and retained messages stay at the broker; no MQTT 5 enhanced authentication (`AUTH`); a topic bound to a token's subject does not tell two issuers apart (one issuer per tenant, or a claim); AWS IoT Core and Azure IoT Hub are not served brokers; one Sparkplug host application per tenant through the gateway, its commands governed only when it goes through the gateway; the gateway never requests a rebirth; OPC UA PubSub in JSON only (no UADP, no client-server); Sparkplug conformance kit not run yet; performance benches written, not run yet - no figure is promised |
| **Since** | `1.7.0` |
| **Configure** | [MQTT devices: the listener in proxy](https://flexway.io/en/docs/operations-mqtt-devices/), [Sparkplug B and OPC UA PubSub JSON](https://flexway.io/en/docs/operations-sparkplug/), [Console: the Devices screen](https://flexway.io/en/docs/operations-console-devices/); connecting a device: [Connecting an MQTT device](https://flexway.io/en/docs/developer-mqtt-devices/) |
