Details about MQTT Clients connected to MQTT Distributor can be found in the Distributor Info folder in the MQTT Distributor tag provider.

Distributor Info tags were expanded in v4.0.18 to provide information about each connected client


where:

Name

Data Type

Description

Connected ClientsIntegerThe number of the MQTT Clients currently connected
Keep Inactive ClientsBooleanA writeable tag that controls whether to include inactive clients in Distributor Info tags (available 4.0.18 onward)
MQTT Clients

Dataset

String Array

String Array

String Array

Boolean Array

DateTime Array

DateTime Array

A dataset containing information about each connected client (available 4.0.18 onward). The following Column Names are included the dataset:

ClientId 

Username 

IP Address

Connected

Last Connect Time

Last Disconnect Time

Total ClientsIntegerThe total number of clients that have connected since the last MQTT Distributor restart (available 4.0.18 onward)


Executing the code below in the Ignition Script Console will print out the values in the MQTT Clients dataset for review:

print ("Number of Connected Clients: " + str(system.tag.readBlocking("[MQTT Distributor]Distributor Info/Connected Clients")[0].value))
print ("Keep Inactive Clients: " + str(system.tag.readBlocking("[MQTT Distributor]Distributor Info/Keep Inactive Clients")[0].value))
print ("Total clients that have connected since last MQTT Distributor restart: " + str(system.tag.readBlocking("[MQTT Distributor]Distributor Info/Total Clients")[0].value))

clients = system.dataset.toPyDataSet(system.tag.readBlocking("[MQTT Distributor]Distributor Info/MQTT Clients")[0].value)      
print ("MQTT Client details:")
for row in clients:
	data = []
	data.append(["Client ID", row[0]])
	data.append(["Username", row["Username"]])
	data.append(["IP Address", row["IP Address"]])
	data.append(["Connected", row["Connected"]])
	data.append(["Last Connect Time", row["Last Connect Time"]])
	data.append(["Last Disconnect Time", row["Last Disconnect Time"]])
	print data


Example result from the Distributor Info > MQTT Clients 

>>> 
Number of Connected Clients: 4
Keep Inactive Clients: True
Total clients that have connected since last MQTT Distributor restart: 6
MQTT Client details:
[['Client ID', u'MT-abf45d02-4c23-4489'], ['Username', u'admin'], ['IP Address', u'127.0.0.1'], ['Connected', False], ['Last Connect Time', Fri Sep 22 16:01:43 CDT 2023], ['Last Disconnect Time', Fri Sep 22 16:04:32 CDT 2023]]
[['Client ID', u'ME-d631ab45-4466-42f0'], ['Username', u'admin'], ['IP Address', u'127.0.0.1'], ['Connected', True], ['Last Connect Time', Fri Sep 22 16:01:42 CDT 2023], ['Last Disconnect Time', None]]
[['Client ID', u'MT-6697e6f5-35fe-471f'], ['Username', u'admin'], ['IP Address', u'127.0.0.1'], ['Connected', True], ['Last Connect Time', Fri Sep 22 16:04:34 CDT 2023], ['Last Disconnect Time', None]]
[['Client ID', u'MT-12c7ca46-e2ec-416c'], ['Username', u'admin'], ['IP Address', u'127.0.0.1'], ['Connected', False], ['Last Connect Time', Fri Sep 22 16:01:43 CDT 2023], ['Last Disconnect Time', Fri Sep 22 16:04:32 CDT 2023]]
[['Client ID', u'MT-04edd7b9-b7ad-455d'], ['Username', u'admin'], ['IP Address', u'127.0.0.1'], ['Connected', True], ['Last Connect Time', Fri Sep 22 16:04:34 CDT 2023], ['Last Disconnect Time', None]]
[['Client ID', u'MT-RPC-73ecfe46-2a63-41'], ['Username', u'admin'], ['IP Address', u'127.0.0.1'], ['Connected', True], ['Last Connect Time', Fri Sep 22 16:04:32 CDT 2023], ['Last Disconnect Time', Fri Sep 22 16:04:32 CDT 2023]]
>>>

Additional Information on MQTT Engine and Transmission Clients

MQTT Engine Clients

MQTT Engine has two potential client connections per MQTT Server setting.

One, with ClientId in the format ME-xxxxxxx-xxxx-xxxx, will publish the v3.0.0 Sparkplug™ B STATE message which will be initiated by default.

A second optional client, with ClientId in the format ME-LS-xxxxxxxx-xxxx-xx, is available to publish the legacy Sparkplug™ B STATE message and is disabled by default.


MQTT Transmission Clients

Each Sparkplug Edge Node Descriptor (which is the Group ID and Edge Node ID combination) will create an MQTT client.

For example, a single Transmitter configuration with the following Sparkplug Edge Node Descriptors will result in three Sparkplug MQTT clients:

Group1/EdgeNode1
Group1/EdgeNode2
Group2/EdgeNode1

A Transmission ClientId is in the format MT-xxxxxxxx-xxxx-xxxx

The MQTT Transmission Transmitters and Tag Trees document describes how transmitters and tag trees can be arranged, which in turn will define how many MQTT clients get created from a single Transmission instance.

In addition, MQTT Transmission supports an optional RPC Client, ClientId MT-RPC-xxxxxxxx-xxxx-xxxx, which is used when publishing from Ignition Python scripts. This is enabled by default.



Additional Resources





  • No labels