Explainer
Why MQTT JSON into Ignition tags needs a bridge outside Jython
Short answer
Yes, without the native MQTT module, but not from a gateway script. Ignition scripts run on Jython 2.7, where the Paho Python MQTT client does not work, and a script cannot stand up its own tag provider. Terminate MQTT in a bridge outside Ignition: a database bridge with query tags is the default, a co-hosted WebSocket service when a poll cycle is too slow, and the native module when Sparkplug B semantics matter.

On this page
Yes, MQTT JSON can reach Ignition tags without the native MQTT module, but not from a gateway script. Ignition scripting runs on Jython 2.7, and the Paho Python MQTT client does not run on that interpreter, so the subscriber has to live somewhere else. The answer is to terminate MQTT in a bridge outside Ignition, most often a separate subscriber writing to a database that query tags read, and to own reconnect, parsing and staleness in that bridge. When you can install a module, the MQTT Engine module still owns the client lifecycle and its own tag provider; a bridge is what you build when you cannot.
Where the packet stops #
Trace the path before writing a line of parsing code: publisher, broker, subscriber, parser, integration layer, tag. Ignition tags do not appear because some process received the message; they appear only when the last two stages write them. A JavaScript MQTT-over-WebSocket page in a browser proves only that the broker can be reached from that page, a pattern covered in sending Sparkplug B payloads over an MQTT WebSocket client, and closing the tab kills the subscriber. That makes a browser the wrong ownership boundary for tag acquisition.
Before touching JSON, confirm the subscriber can resolve and reach the broker address, that a WebSocket consumer points at the broker's WebSocket listener rather than its raw MQTT listener, and that the topic filter and access policy allow the publisher's topics. A connected subscriber that receives nothing is a topic or permissions problem, not a parser problem. Record the address, listener port and topic from configuration instead of assuming conventional defaults.
Why the client cannot live in a gateway script #
Two limits rule it out.
First, the interpreter. The current Ignition scripting release is Jython 2.7: Python 2.7 semantics running on a Java virtual machine, not CPython. The Paho Python MQTT client targets CPython and does not run on Jython, so a gateway script built on that stack is a dead branch. Dropping a Java MQTT client library next to the gateway is not the same as installing a module either; module development is a different job than scripting.
Second, the tag provider. A purpose-built module can create and own a tag provider. The scripting functions create and edit tags inside providers that already exist, but you cannot easily stand up a new provider from a gateway script, so a script-based client has no clean place to publish and ends up maintaining tag state by hand.
Add the lifecycle work on top: the client must start with the gateway service, reconnect after a broker or network loss, restore its subscriptions, stop cleanly, report connection state, and avoid spawning a duplicate consumer after a script restart. Why an MQTT client reconnects but then publishes nothing shows how that lifecycle fails in practice. JSON parsing is one small step of that job.
The three bridge designs #
| Design | Where MQTT terminates | How values reach tags | What you own |
|---|---|---|---|
| Native MQTT module | Inside the gateway | Module-managed tag provider | Configuration and payload mapping |
| Database bridge | Separate subscriber process | Query tags read the newest accepted row | Writes, freshness, cleanup and query behavior |
| WebSocket service | Separate subscriber, often co-hosted | Gateway reads the parsed JSON over WebSocket | Reconnect, parsing, buffering and health reporting |
The database bridge is the pattern to reach for first: a standalone MQTT subscriber, which can be any well-supported client, writes each payload or its extracted values to a table, and Ignition reads through query tags. One external consumer of this kind is worked through in run a JSON SCADA MQTT driver instance and extract payload values.
Which bridge to build #
Commit by payload type and required behavior:
- Sparkplug B payloads: use the native module. A hand parser can read the JSON, but Sparkplug B adds birth and death certificates, sequence numbers and a computed online or offline state per edge node; parsing payloads does not reproduce that contract.
- Plain JSON where auditability or later replay matters: the database bridge, and keep it as your default even when they do not. Query tags give you quality, timestamps and a poll rate you control, and the table doubles as the record.
- Plain JSON where the poll cycle is too slow: a co-hosted WebSocket service. The Web Dev module documents that the value you return is either a string that should be valid JSON or a Python object that gets encoded into a JSON string, and that is your serving interface. Run the service on the same host as the gateway to cut network hops, while remembering the two processes still fail separately.
- A browser page: never as the sole acquisition path.
The staleness rule, with numbers #
A last good value must never look live forever. Take example inputs of a publisher sending every 1000 ms and a query tag polling every 2000 ms. The worst-case age of the value the tag displays is the publish interval plus the poll interval: 1000 ms + 2000 ms = 3000 ms. Set the staleness threshold at twice that worst case: 2 × 3000 ms = 6000 ms. A row whose source timestamp is older than that threshold drives the tag to bad quality; anything newer is good. Apply the same arithmetic with your own publish and poll numbers, and write both a source timestamp and an ingestion timestamp into every row so replayed old data cannot pass as fresh.
Mapping the JSON to tags #
Capture the raw payload before defining a single tag. Validate that each message is valid JSON, identify the object path for every required field, and decide in advance how to treat missing keys, nulls, arrays, type changes and malformed messages. Reject incompatible values before writing them and never silently substitute zero. When the database carries the bridge, query only the newest accepted record per key, and keep the last accepted source timestamp distinct from the displayed process value so a frozen feed is visible as such.
Proving the path end to end #
Force a controlled interruption once the bridge is built. Stop the broker, confirm the subscriber reports disconnected, restart it, then confirm the subscription resumes, the tags refresh with new timestamps, and exactly one consumer instance exists. Compare source, ingestion and tag timestamps on a known point. A path that survives that test is a bridge; one that has not been through it is an assumption.
Questions asked
Can a gateway script create its own tag provider?
No. A tag provider comes from a module. The scripting functions create and edit tags inside providers that already exist, which is why a script-based MQTT client ends up hand-maintaining tags in a default provider instead of owning a clean namespace.
Does the Web Dev module write MQTT values into tags by itself?
No. The Web Dev documentation describes the interface side: the value a page returns is either a string that should be valid JSON or a Python object that gets encoded into a JSON string. Moving those values into tags still takes a script, a query path or a module.
What happens to tags during a broker outage on a database bridge?
The newest row stops advancing, so the staleness rule drives the tags to bad quality instead of showing a frozen value as live. If the subscriber buffers messages, they arrive after the outage with their original source timestamps, and the separate ingestion timestamp lets you tell replayed data from fresh data.
Is a browser MQTT-over-WebSocket page ever the right subscriber?
Only for demos and diagnostics. The subscription lives in the browser session, so closing the tab or losing the laptop ends data acquisition, and the page has no path into gateway-scoped tags without extra forwarding code. Use it to prove broker reachability, then build the real subscriber as a service.


