MQTT Config Reference
Below is a comprehensive list of each configuration option on the MQTT driver with its default, a description of its purpose and what effect it will have.
The driver options are set on the Drivers screen. The options a tag uses to subscribe to a topic are set per tag on the Tags screen, and are listed under Subscriber tag properties. The MQTT broker built into the OAS engine is configured on the Options screen, not on the driver, and has its own page: MQTT Broker.
Minimum configuration requirements
These are the fields that need a value before the driver will do anything. Everything else has a working default.
| Field | Needed for | Notes |
|---|---|---|
| Driver Interface Name | Both | The name tags refer to in Select Driver Interface. |
| Driver | Both | Set to MQTT. |
| IP Address | Both | Blank by default. The IP address or host name of the broker. |
| Port | Both | Defaults to 1883. A broker using TLS usually listens on a separate secure port, commonly 8883. |
| Client ID | Both | Defaults to OAS_Client. It must be unique on the broker, so give each driver interface its own. |
| Enable | Both | The interface is not active until this is on and the changes are applied. |
| Publish Selected Tags | Publishing | Off by default. A driver interface with this off only subscribes. |
| Tags To Publish | Publishing | Nothing is published until tags are added. |
| Topic | Subscribing | Set on the tag, not on the driver. |
Driver interface
| Property | Default | Notes |
|---|---|---|
| Driver Interface Name | - | The name used to identify this driver interface. Tags reference it from their Select Driver Interface property. |
| Driver | Modbus | Set to MQTT to publish and subscribe to an MQTT broker. |
| Enable | on | Enable communications. Hidden when Enable by Tag is on. |
| Enable by Tag | off | Enable and disable the driver from a Boolean tag instead, named in Enable Tag. |
| Good Quality When Disabled | off | On: tags on this driver keep good quality while the driver is disabled, and can be written to. Off: they go to bad quality. |
| Simulate | off | Disable communications and hold every value static with good quality. |
| Return to Online | 60 Seconds | How often to re-check communications after the interface has been taken offline. With failover enabled, this is the retry frequency when both the primary and the failover broker are offline. |
Connection
| Property | Default | Notes |
|---|---|---|
| IP Address | blank | The network address of the broker. Enter an IP address or a host name reachable from the engine. |
| Port | 1883 | The port number of the broker. |
| User Name | blank | The user name for the connection, where the broker requires one. |
| Password | blank | The password for the connection. |
| Keep Alive Time | 60 Seconds | The keep alive time for the connection. |
| Session Expiry Interval | 0 Seconds | The session expiry interval for the connection. Shown when the Protocol Version is V500. |
| Reconnect Time | 1 Seconds | If the connection to the broker is lost, how long to wait before attempting to reconnect. |
| Buffer Timeout | 0 Seconds | The time the broker has to respond after a write. If it does not respond in that time the buffer is cleared. |
| Max Buffer Messages | 30000 | The maximum number of messages that are queued before older messages are dropped. |
| Retain Messages | off | Retain messages when they are published. |
| Protocol Version | V311 | V310, V311 or V500. |
| Client ID | OAS_Client | The unique identifier the broker uses to track this connection. It must be unique per broker - two clients cannot be connected with the same Client ID at the same time. |
TLS
The certificate fields are shown when TLS is on. Which of them are shown depends on Create Certificate: on, the certificate is given as separate certificate and private key files; off, it is given as a PFX file and its password.
| Property | Default | Notes |
|---|---|---|
| TLS | off | Enable TLS for the connection. A broker using TLS usually listens on a separate secure port, commonly 8883, so change the Port as well. |
| TLS Version | TLS13 | TLS12 or TLS13. |
| Create Certificate | on | On: create the certificate from the Client Certificate File and Client Private Key File. Off: load a PFX certificate file instead. Turn it off and define the PFX certificate file when the engine is running on Linux. |
| Client Certificate File | blank | The file path for the client certificate. Shown when Create Certificate is on. |
| Client Private Key File | blank | The file path for the client private key. Shown when Create Certificate is on. |
| Client PFX Certificate File | blank | The file path for the client PFX certificate file to load. Shown when Create Certificate is off. |
| Client PFX Certificate Password | blank | The password for the client PFX certificate file. Shown when Create Certificate is off. |
| Server Certificate File | blank | The file path for the server certificate. For a broker with a self-signed or private CA certificate, set this to the broker's certificate or to a CA it chains to. Shown when Create Certificate is on. |
| Server PFX Certificate File | blank | The file path for the server PFX certificate file to load. Shown when Create Certificate is off. |
| Server PFX Certificate Password | blank | The password for the server PFX certificate file. Shown when Create Certificate is off. |
| Allow Invalid Certificate | off | Accept a broker certificate that fails security verification. Leave it off unless you trust the endpoint - it is for testing, not for production. |
Message format New
Shown when Publish Selected Tags is on.
| Property | Default | Notes |
|---|---|---|
| Output Format | Default | Default - JSON, with field names taken from the payload field names. ISA-95 Lite - the built-in unified namespace schema. Custom AVRO Schema - your own schema. The MQTT driver publishes the schema formats as JSON text. Download .avsc, shown beside it for the two schema formats, saves the AVRO schema the driver publishes under, as it was last applied. |
| AVRO Schema | blank | The AVRO schema the message is published against, and which part of a tag fills each of its fields. Both are built in the Edit AVRO schema dialog, opened with Edit… - see The Edit AVRO schema dialog. Shown when the Output Format is Custom AVRO Schema. |
| Batched Messages New | on | On, with a schema that has a tag array or tag map: the tags of each publish that share a topic go in one message, up to Max Tags Per Publish. Off: each tag is a message of its own. Shown when the Output Format is Custom AVRO Schema. The same switch is in the Edit AVRO schema dialog. |
The schemas that Load from library... offers in that dialog are kept in the Message Schemas section of the Options screen, which the MQTT broker also uses - see Message Schemas.
Upgrading
Batched Messages may be stored off on a driver set up before this release. A driver moved to a schema with a tag array or tag map sends one tag per message until it is turned on.
Publishing
Publishing is off until Publish Selected Tags is turned on. A driver interface with it off only subscribes.
| Property | Default | Notes |
|---|---|---|
| Publish Selected Tags | off | Turns publishing on for this driver interface. |
| Tags To Publish | - | The tags to publish, each with the Id that names it in the message. The Id is also the topic when Publish All Tags As One Topic is off. An Id can be made of parts separated by a vertical bar, such as SITE-A|PQM-1|P01, which {tagIdPart1}, {tagIdPart2} and so on read - see Message Variables. The spaces around each part are dropped. Value is the current value from the data source, or any other tag variable can be selected to publish. New A tag listed more than once, each time with a different Id, is published under every Id - see A tag with several Ids. |
| Publish Type | Continuous | Continuous on an interval, Event Driven from a trigger tag, or Specific Time of Day. |
| Publish Interval | 10 Seconds | Continuous only. |
| Publish On Startup | on | Continuous only. Publish immediately on startup rather than waiting out the first interval. |
| Trigger Tag | - | Event Driven only. A Boolean tag triggers on transition; an Integer tag triggers whenever its value changes to a non-zero value. |
| Digital Trigger Type | False to True | Event Driven only. False to True, True to False or Both. |
| Time of Day | - | Specific Time of Day only. |
| Publish Latest Value Only | on | On: publish only the current value of each tag. Off: publish every value change since the last publish. |
| Publish Boolean As Number | off | Publish 1 and 0 rather than true and false. |
| Include All Tags Each Publish | off | Include every selected tag in each publish, even the ones that have not changed. |
| Include Tags For Period | off | Include all tag values in each publish for the period set in Include Tags Time, then drop the unchanged ones from further publishing. The period defaults to 1 second. |
| Publish All Tags As One Topic | on | On: all values are sent together as one topic, Publish Topic Id. Off: each tag is sent as its own topic, named by its Id in Tags To Publish. |
| Max Tags Per Publish | 1000 | The maximum number of tags to include in each transmission. If there are more tag values to publish than this, several transmissions are sent on the same topic, in order, instead of one. With a topic pattern it limits each topic's message, and with a tag array or tag map it limits the tags in one message. With ISA-95 Lite or Custom AVRO Schema, 0 means no limit. Shown when Publish All Tags As One Topic is on. |
| Publish Topic Id | oas_tags | The topic used when Publish All Tags As One Topic is on. New It can be a topic pattern, such as plant/{groupPathSlash}, that gives each tag a topic of its own. |
| Override Value When Bad | None | What to publish when a tag's quality is bad: None (publish it bad), Do Not Send, Hold Last Value, Set To Value or Hold Then Set. |
| Override Time | 60 Seconds | How long to hold the last good value. Shown for Hold Last Value and Hold Then Set. |
| Value When Bad | 0 | The value to publish instead. Shown for Set To Value and Hold Then Set. |
Topic patterns New
With Publish All Tags As One Topic on, Publish Topic Id can hold message variables in braces, so one driver interface publishes to many topics. Each tag goes to the topic the pattern gives it, and the tags of one publish that share a topic share a message. This works with every Output Format.
| Publish Topic Id | Result |
|---|---|
oas_tags | All tags to oas_tags, as before. |
plant/{groupPathSlash} | One topic per group: plant/Plant/Line1, plant/Plant/Line2. |
company/{siteId}/{area}/{workCenter}/{workUnit} | One topic per device in the ISA-95 hierarchy. |
oas/{property:Line}/data | One topic per value of the tag property Line. |
- A variable that changes with every value or every message -
{value},{quality}, the timestamps,{uuid}and the others the variable tables mark - cannot be used in a topic. - Text in braces that is not a variable is kept as written. To keep a variable name as text, double its braces:
data/{{site}}publishes ondata/{site}. - A tag whose topic comes out empty, contains
+or#, or has no value for a variable in it, is not published, and System Errors gets one entry for it. - Topics are worked out again once a minute, so a renamed group or a changed property reaches the topic without a restart.
Upgrading
A Publish Topic Id set up before this release that already holds a variable name in braces, such as data/{site}, becomes a pattern. Double the braces to keep them as text.
Topic preview
The line under Publish Topic Id in the web app checks the text as you type:
- Topic pattern. or One topic. says which the text is, with an example topic.
- Insert a variable… adds a variable at the cursor.
- Try a tag… picks a tag and shows the topic it would get. Try another tag… picks a different one.
- Not published: … says why the tag tried would not be published.
- A warning names any text in braces that is not a variable, which is published as written, and any variable that changes with every value or message, which a topic may not use.
A tag with several Ids New
Tags To Publish can list the same tag more than once, each time with a different Id. The driver publishes the tag under every Id:
| Setup | Result for a tag listed with two Ids |
|---|---|
Default format, one topic | Two entries in the message, one per Id. |
| Publish All Tags As One Topic off | Two messages, each on its own Id's topic. |
A schema whose mapping reads the Id (Tag ID, {tagId}) | Two entries, one per Id. |
| A schema whose mapping does not read the Id | One entry: both would be the same. |
A topic pattern with {tagId} | Two topics, one per Id. |
With a tag map keyed by something other than the Id, while another field reads it, both Ids give the same key: the last Id is kept, and System Errors notes it once.
Upgrading
Before this release the MQTT driver published only a tag's first Id. To keep that, remove the extra rows from Tags To Publish.
Payload field names
These name the fields inside a Default format message. They do not apply to ISA-95 Lite or Custom AVRO Schema, where the schema's field mapping sets the names, the quality and the timestamps.
Default. Values saved before the format was changed are kept. Within Default, Payload Name, the payload timestamp and payload id fields, Values Id and Publish Tag Id are shown only when Publish All Tags As One Topic is on. Publish Value Id, Include Quality, Include Timestamp and the fields beneath them are shown either way.| Property | Default | Notes |
|---|---|---|
| Payload Name | blank | An optional identifier for the entire payload that is published. Leave it blank to leave the identifier out. |
| Include Payload Timestamp | off | Include a timestamp for the payload as a whole. |
| Include In Each Value | off | Include the payload timestamp with each value as well. Shown when Include Payload Timestamp is on. |
| Payload Timestamp Id | timestamp | The field carrying the payload timestamp. Shown when Include Payload Timestamp is on. |
| Payload Timestamp Type | ISO 8601 | ISO 8601, Unix, Unix ms, Ticks or Custom. Shown when Include Payload Timestamp is on. |
| Format (payload timestamp) | yyyy-MM-dd HH:mm:ss.ffffff | Shown when the Payload Timestamp Type is Custom. |
| Include Payload Id | off | Include an identifier for the payload. |
| Payload Id Name | id | The name of the identifier field. Shown when Include Payload Id is on. |
| Payload Id | data | The identifier itself. Shown when Include Payload Id is on. |
| Values Id | values | The name of the array that holds the values. |
| Publish Tag Id | id | The field carrying each tag's identifier. |
| Publish Value Id | value | The field carrying the value. |
| Include Quality | on | Include the quality with each value. |
| Id (quality) | quality | The field carrying the quality. |
| Include Timestamp | on | Include the timestamp with each value. |
| Id (timestamp) | timestamp | The field carrying the timestamp. |
| Timestamp Type | ISO 8601 | ISO 8601, Unix, Unix ms, Ticks or Custom. |
| Format (timestamp) | yyyy-MM-dd HH:mm:ss.ffffff | Shown when the Timestamp Type is Custom. |
Payload examples
With the defaults, every tag is published to the one topic named by Publish Topic Id.
Topic: oas_tags
{
"values": [
{
"id": "Ramp",
"value": 39,
"quality": true,
"timestamp": "2022-03-21T08:55:39.000Z"
},
{
"id": "Sine",
"value": 0.8090169943749475,
"quality": true,
"timestamp": "2022-03-21T08:55:39.000Z"
},
{
"id": "Random",
"value": 10,
"quality": true,
"timestamp": "2022-03-21T08:55:39.000Z"
}
]
}
With Publish Latest Value Only off the message has the same shape, but carries every value change since the last publish, so a tag that changed twice appears twice.
With Publish All Tags As One Topic off, each tag is published to a topic of its own, named by its Id.
Topic: Ramp
{
"value": 35,
"quality": true,
"timestamp": "2022-03-21T09:07:15.000Z"
}
Topic: Sine
{
"value": -1,
"quality": true,
"timestamp": "2022-03-21T09:07:15.000Z"
}
Store and Forward
| Property | Default | Notes |
|---|---|---|
| Enable Store and Forward | off | Buffer values when the broker cannot be reached, rather than discarding them, and forward them once communication is restored. |
| Last In First Out | off | Process buffered data newest first. Shown when Store and Forward is on, and requires Store Buffer to Disk. |
Info
Where the buffer is kept is not a driver property. It is set once for the whole engine under Configure → Options → Store and Forward: Store Buffer to Disk, Directory for Buffer, Limit Disk Buffering and, for buffering data published from a remote engine, Buffer Data for Remote IoT Publish.
Failover
Shown when Enable Failover is on. These describe a second broker, with its own address, credentials and certificates, that the driver moves to when the primary broker fails.
| Property | Default | Notes |
|---|---|---|
| Enable Failover | off | Enable fail over to the backup connection when the primary interface fails. |
| Failover IP Address | blank | The network address of the failover broker. |
| Failover Port | 1883 | The port number of the failover broker. |
| Failover User Name | blank | The user name for the connection when in failover. |
| Failover Password | blank | The password for the connection when in failover. |
| Failover Create Certificate | on | As Create Certificate, for the failover connection. Shown when TLS is on. |
| Failover Client Certificate File | blank | Shown when Failover Create Certificate is on. |
| Failover Client Private Key File | blank | As above. |
| Failover Client PFX Certificate File | blank | Shown when Failover Create Certificate is off. |
| Failover Client PFX Certificate Password | blank | As above. |
| Failover Server Certificate File | blank | Shown when Failover Create Certificate is on. |
| Failover Server PFX Certificate File | blank | Shown when Failover Create Certificate is off. |
| Failover Server PFX Certificate Password | blank | As above. |
Communication status
Each of these sets a Boolean tag from the state of the driver interface. Turning one on shows the field that names the tag: Comm Bad Tag, Comm Good Tag or Comm Buffering Tag.
| Property | Default | Notes |
|---|---|---|
| Comm Bad | off | Set a tag to true while the driver interface is enabled and in communication failure. |
| Comm Good | off | Set a tag to true while the driver interface is enabled and communications are good. |
| Comm Buffering | off | Set a tag to true while the driver interface is enabled and in Store and Forward. |
Subscriber tag properties
A tag subscribes to a topic through its own properties on the Tags screen, not through the driver.
| Property | Default | Notes |
|---|---|---|
| Data Source | - | Set to MQTT. |
| Select Driver Interface | - | The MQTT driver interface the tag subscribes through. |
| Topic | blank | The MQTT topic this parameter subscribes to for its value. |
| Quality Of Service | AtMostOnce | AtMostOnce, AtLeastOnce or ExactlyOnce. |
| Topic Timeout | 0 Seconds | If an update is not received from the broker in this time, the tag value is set to bad data quality. 0 disables the timeout, so the topic never times out. |
| Include Timestamp | off | Include the timestamp in the MQTT data. |
| Include Quality | off | Include the quality in the MQTT data. |
| Read Only | off | The value cannot be written to. |
| Write Only | off | The value is not read from the topic, but writes are allowed. |
Troubleshooting
| Symptom | Cause |
|---|---|
| The connection fails as soon as TLS is turned on | The Port is still 1883. With TLS, use the broker's secure port - commonly 8883. |
| The broker's certificate is rejected | The broker uses a self-signed or private CA certificate. Set Server Certificate File to the broker's certificate, or to a CA it chains to. Allow Invalid Certificate gets past it, but only for testing. |
| A subscribed tag does not read its value, or the connection keeps dropping | Another client is connected to the broker with the same Client ID. Each connection needs a Client ID of its own. |
| A tag goes to bad quality while the broker is connected | The tag's Topic Timeout is greater than 0 and no message arrived on the topic in that time. 0 never times out. |
| The driver does not communicate at all | The default network adapter priority in the operating system may need to be set. |
Where next
- Getting Started with MQTT - these options in a working configuration.
- MQTT How-To guides - logging, transferring and routing MQTT data.
- Message Schemas - the schema library and the Edit AVRO schema dialog.
- Message Variables - every variable a topic pattern or a schema can use.
