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.

FieldNeeded forNotes
Driver Interface NameBothThe name tags refer to in Select Driver Interface.
DriverBothSet to MQTT.
IP AddressBothBlank by default. The IP address or host name of the broker.
PortBothDefaults to 1883. A broker using TLS usually listens on a separate secure port, commonly 8883.
Client IDBothDefaults to OAS_Client. It must be unique on the broker, so give each driver interface its own.
EnableBothThe interface is not active until this is on and the changes are applied.
Publish Selected TagsPublishingOff by default. A driver interface with this off only subscribes.
Tags To PublishPublishingNothing is published until tags are added.
TopicSubscribingSet on the tag, not on the driver.

Driver interface

PropertyDefaultNotes
Driver Interface Name-The name used to identify this driver interface. Tags reference it from their Select Driver Interface property.
DriverModbusSet to MQTT to publish and subscribe to an MQTT broker.
EnableonEnable communications. Hidden when Enable by Tag is on.
Enable by TagoffEnable and disable the driver from a Boolean tag instead, named in Enable Tag.
Good Quality When DisabledoffOn: tags on this driver keep good quality while the driver is disabled, and can be written to. Off: they go to bad quality.
SimulateoffDisable communications and hold every value static with good quality.
Return to Online60 SecondsHow 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

PropertyDefaultNotes
IP AddressblankThe network address of the broker. Enter an IP address or a host name reachable from the engine.
Port1883The port number of the broker.
User NameblankThe user name for the connection, where the broker requires one.
PasswordblankThe password for the connection.
Keep Alive Time60 SecondsThe keep alive time for the connection.
Session Expiry Interval0 SecondsThe session expiry interval for the connection. Shown when the Protocol Version is V500.
Reconnect Time1 SecondsIf the connection to the broker is lost, how long to wait before attempting to reconnect.
Buffer Timeout0 SecondsThe time the broker has to respond after a write. If it does not respond in that time the buffer is cleared.
Max Buffer Messages30000The maximum number of messages that are queued before older messages are dropped.
Retain MessagesoffRetain messages when they are published.
Protocol VersionV311V310, V311 or V500.
Client IDOAS_ClientThe 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.

PropertyDefaultNotes
TLSoffEnable TLS for the connection. A broker using TLS usually listens on a separate secure port, commonly 8883, so change the Port as well.
TLS VersionTLS13TLS12 or TLS13.
Create CertificateonOn: 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 FileblankThe file path for the client certificate. Shown when Create Certificate is on.
Client Private Key FileblankThe file path for the client private key. Shown when Create Certificate is on.
Client PFX Certificate FileblankThe file path for the client PFX certificate file to load. Shown when Create Certificate is off.
Client PFX Certificate PasswordblankThe password for the client PFX certificate file. Shown when Create Certificate is off.
Server Certificate FileblankThe 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 FileblankThe file path for the server PFX certificate file to load. Shown when Create Certificate is off.
Server PFX Certificate PasswordblankThe password for the server PFX certificate file. Shown when Create Certificate is off.
Allow Invalid CertificateoffAccept 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.

PropertyDefaultNotes
Output FormatDefaultDefault - 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 SchemablankThe 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 NewonOn, 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.

PropertyDefaultNotes
Publish Selected TagsoffTurns 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 TypeContinuousContinuous on an interval, Event Driven from a trigger tag, or Specific Time of Day.
Publish Interval10 SecondsContinuous only.
Publish On StartuponContinuous 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 TypeFalse to TrueEvent Driven only. False to True, True to False or Both.
Time of Day-Specific Time of Day only.
Publish Latest Value OnlyonOn: publish only the current value of each tag. Off: publish every value change since the last publish.
Publish Boolean As NumberoffPublish 1 and 0 rather than true and false.
Include All Tags Each PublishoffInclude every selected tag in each publish, even the ones that have not changed.
Include Tags For PeriodoffInclude 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 TopiconOn: 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 Publish1000The 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 Idoas_tagsThe 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 BadNoneWhat 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 Time60 SecondsHow long to hold the last good value. Shown for Hold Last Value and Hold Then Set.
Value When Bad0The 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 IdResult
oas_tagsAll 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}/dataOne 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 on data/{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:

SetupResult for a tag listed with two Ids
Default format, one topicTwo entries in the message, one per Id.
Publish All Tags As One Topic offTwo 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 IdOne 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.

New All of them are shown only when the Output Format is 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.
PropertyDefaultNotes
Payload NameblankAn optional identifier for the entire payload that is published. Leave it blank to leave the identifier out.
Include Payload TimestampoffInclude a timestamp for the payload as a whole.
Include In Each ValueoffInclude the payload timestamp with each value as well. Shown when Include Payload Timestamp is on.
Payload Timestamp IdtimestampThe field carrying the payload timestamp. Shown when Include Payload Timestamp is on.
Payload Timestamp TypeISO 8601ISO 8601, Unix, Unix ms, Ticks or Custom. Shown when Include Payload Timestamp is on.
Format (payload timestamp)yyyy-MM-dd HH:mm:ss.ffffffShown when the Payload Timestamp Type is Custom.
Include Payload IdoffInclude an identifier for the payload.
Payload Id NameidThe name of the identifier field. Shown when Include Payload Id is on.
Payload IddataThe identifier itself. Shown when Include Payload Id is on.
Values IdvaluesThe name of the array that holds the values.
Publish Tag IdidThe field carrying each tag's identifier.
Publish Value IdvalueThe field carrying the value.
Include QualityonInclude the quality with each value.
Id (quality)qualityThe field carrying the quality.
Include TimestamponInclude the timestamp with each value.
Id (timestamp)timestampThe field carrying the timestamp.
Timestamp TypeISO 8601ISO 8601, Unix, Unix ms, Ticks or Custom.
Format (timestamp)yyyy-MM-dd HH:mm:ss.ffffffShown 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

PropertyDefaultNotes
Enable Store and ForwardoffBuffer values when the broker cannot be reached, rather than discarding them, and forward them once communication is restored.
Last In First OutoffProcess 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.

PropertyDefaultNotes
Enable FailoveroffEnable fail over to the backup connection when the primary interface fails.
Failover IP AddressblankThe network address of the failover broker.
Failover Port1883The port number of the failover broker.
Failover User NameblankThe user name for the connection when in failover.
Failover PasswordblankThe password for the connection when in failover.
Failover Create CertificateonAs Create Certificate, for the failover connection. Shown when TLS is on.
Failover Client Certificate FileblankShown when Failover Create Certificate is on.
Failover Client Private Key FileblankAs above.
Failover Client PFX Certificate FileblankShown when Failover Create Certificate is off.
Failover Client PFX Certificate PasswordblankAs above.
Failover Server Certificate FileblankShown when Failover Create Certificate is on.
Failover Server PFX Certificate FileblankShown when Failover Create Certificate is off.
Failover Server PFX Certificate PasswordblankAs 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.

PropertyDefaultNotes
Comm BadoffSet a tag to true while the driver interface is enabled and in communication failure.
Comm GoodoffSet a tag to true while the driver interface is enabled and communications are good.
Comm BufferingoffSet 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.

PropertyDefaultNotes
Data Source-Set to MQTT.
Select Driver Interface-The MQTT driver interface the tag subscribes through.
TopicblankThe MQTT topic this parameter subscribes to for its value.
Quality Of ServiceAtMostOnceAtMostOnce, AtLeastOnce or ExactlyOnce.
Topic Timeout0 SecondsIf 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 TimestampoffInclude the timestamp in the MQTT data.
Include QualityoffInclude the quality in the MQTT data.
Read OnlyoffThe value cannot be written to.
Write OnlyoffThe value is not read from the topic, but writes are allowed.

Troubleshooting

SymptomCause
The connection fails as soon as TLS is turned onThe Port is still 1883. With TLS, use the broker's secure port - commonly 8883.
The broker's certificate is rejectedThe 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 droppingAnother 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 connectedThe 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 allThe default network adapter priority in the operating system may need to be set.

Where next