MQTT Connection Tag

Help Contents

Introduction

The MQTT Connection Tag Channel Tag Icon provides a SCADA/HMI communication channel to Message Queuing Telemetry Transfer (MQTT) server.

You can associate I/O Data Tags with an MQTT Connection tag. When the association is made:

Configuration Properties

The MQTT Connection Tag supports the properties of the Active Channel Tag plus these properties:

PropertyTypeVersionDescription
EnableDirectWrite BOOL 3.25 Whether the DirectWrite tag commands are allowed on this tag.
HostName WSTRING 3.22 The host name or IP address of the MQTT Server.
MaxRxMessageSize UDINT 3.22 The maximum size of message the MQTT driver will read from an MQTT Server. If an MQTT Server sends a message larger than this limit, the MQTT Driver will drop the connection. Following a disconnect event, the MQTT Driver will automatically try and reconnect to the MQTT server after a timeout period.

Note: This value is clamped internally to the range 64 to 65536.

MaxTxMessageSize UDINT 3.22 The maximum size of message sent by Fernhill SCADA to an MQTT Server. If you make this value artificially small, you may see the following side effects:
  • Tags with long topic names may fail to subscribe because the subscription request would exceed this limit.
  • Write requests may fail if the Publish message exceeds this limit.

Note: This value is clamped internally to the range 64 to 65536.

PortNumber WSTRING 3.22 The port number used for communications. The default port number for MQTT is 1883.
UseTLS BOOL 3.25 Whether the connection to the MQTT server uses Transport Layer Security (TLS). If UseTLS is True the connection uses TLS. If UseTLS is False the connection does not use TLS (no encryption).
Password WSTRING 3.25 The password value sent in the MQTT connection request. Note: The password value is encrypted and not stored as plain text.
UserName WSTRING 3.25 The user name sent in the MQTT connection request
PingInterval TIME 3.22 The interval between each PING request sent from the Fernhill SCADA Driver to the MQTT Server. See Interval and Offset for information on how Intervals and Offsets define the time of activities.
PingOffset TIME 3.22 The offset added to the PingInterval to get the actual ping time. See Interval and Offset for information on how Intervals and Offsets define the time of activities.
LastWillOfflineValue WSTRING 3.26 The value to publish to the LastWillTopic when the MQTT Driver disconnects from the MQTT Server. If the LastWillTopic property is an empty string, this property has no effect.
LastWillOnlineValue WSTRING 3.26 The value to publish to the LastWillTopic when the MQTT Driver connects to the MQTT Server. If the LastWillTopic property is an empty string, this property has no effect.
LastWillTopic WSTRING 3.26 The topic name used for the last will value in the MQTT Server.

MQTT Security

Security in MQTT depends on how the MQTT Server is configured. For successful communication, the configuration of the MQTT Connection Tag should match the configuration of your MQTT Server. MQTT Servers generally provide five security options:

Option Description
Client ID Prefix The MQTT Server may require the Client ID to start with a specified prefix.
Fernhill SCADA uses the prefix string FH in the Client ID sent in the connection request.
User Name The MQTT Server may require a valid user name sent in the connection request.
In Fernhill SCADA, the UserName property configures the user name sent in the connection request.
Password The MQTT Server may require a valid password sent in the connection request.
In Fernhill SCADA, the Password property configures the password sent in the connection request. The password is not shown in diagnostic logs. If you monitor communication using the Data Log Window the password will not be shown.
TLS The MQTT Server may require Transport Layer Security (TLS).
In Fernhill SCADA, the UseTLS property configures whether TLS is used. If UseTLS is True the driver will attempt the connection with TLS. If UseTLS is False the driver will use TCP/IP without encryption.
Client Certificate The MQTT Server may require a valid client certificate during the Transport Layer Security (TLS) connection.
Fernhill SCADA does not currently support a client Certificate.

Information Information: If you have configured a UserName or Password consider using Transport Layer Security (TLS). Transport Layer Security encrypts the connection between Fernhill SCADA and the MQTT Server. Encryption helps to keep the UserName and Password fields private. Without encryption the user name and password may be read by anyone who has access to the network.

Last Will

The LastWillTopic property is optional. If LastWillTopic property is configured it indicates if Fernhill SCADA is online or offline.

When Fernhill SCADA connects to the MQTT Server, the MQTT driver does the following:

  1. The LastWillTopic and LastWillOfflineValue properties are sent in the connection request in the Will Topic and Will Message fields.
  2. The LastWillOnlineValue is published to the LastWillTopic.

When Fernhill SCADA disconnects from the MQTT Server, the MQTT driver does the following:

  1. The LastWillOfflineValue is published to the LastWillTopic.
  2. The driver sends a DISCONNECT message to the MQTT server.

Note: In this clean disconnection scenario, the MQTT server deletes the Will Message without publishing it.

If the connection is lost between the MQTT Server and Fernhill SCADA, The MQTT Server does the following:

  1. The LastWillOfflineValue (sent in the connection request) is published to the LastWillTopic.

Tag Commands

The MQTT Connection Tag supports the tag commands of the Active Channel Tag plus these tag commands:

Tag Command Version Description
DirectWriteBit 3.25 Directly publishes a boolean value to an MQTT topic. The boolean value is published as 'True' or 'False' depending on the value.
DirectWriteString 3.25 Directly publishes a string value to an MQTT topic.

Relationships to Other Tag Types

The MQTT Connection Tag builds on the features of these tag types:

Further Information

Active Channel Tag

To learn about the properties common to all active channels.

Alarm Handling

To learn about alarm management.

Glossary

For the meaning of terms used in Fernhill SCADA.