This document has only the specific information about the device connection settings and its address syntax.
Refer to the User Guide for more information on the Device Module.
Summary
Communication Driver Information | |
---|---|
Driver name | MQTTAzure |
Assembly Name | T.ProtocolDriver.MQTTAzure |
Assembly Version | 1.0.0.3 |
Available for Linux | True |
Devices supported | Any device compatible with the MQTT protocol |
Manufacturer | Microsoft |
Protocol | MQTT (Message Queuing Telemetry Transport) is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol. |
Interface | TCP/IP |
PC Requirements | Ethernet port |
Implemented Methods | Connect, Disconnect, Subscribe, UnSubscribe and Publish. |
Channels Configuration
Protocol Options
Not used in this driver.
Nodes Configuration
Station Configuration
Station syntax: <URL> ; <Port> ; <ClientID> ; <Username> ; <Password> ; <SslProtocol> ; [X509Certificate] ; <PayloadFormat>
Where:
- <URL>: MQTT Broker (Server) name. It must be the same name configured in host Name parameter in Azure IoT Hub.
- <Port>: MQTT Broker port. It must be the same port is configured in the Broker to be listening. Default value is 8883.
- <ClientId>: Device Id configured in Azure IoT Hub.
- <Username>: Username defined on MQTT Broker. Is a concatenation of Host Name and Client Id. Syntax: <URL>/<ClientId>.
- <Password>: Password defined on MQTT Broker. It is the SAS Token defined for the Device Id.
- <SslProtocol>: IoT Hub uses Transport Layer Security (TLS) to secure connections from IoT devices and services. Three versions of the TLS protocol are currently supported, namely versions 1.0, 1.1, and 1.2. TLS 1.0 and 1.1 are considered legacy and are planned for deprecation. For more information, see Deprecating TLS 1.0 and 1.1 in IoT Hub by Microsoft. To avoid future issues, use TLS 1.2 as the only TLS version when connecting to IoT Hub.
- [X509Certificate]: optional = Path of X509 Certificate using TLS v1.0. This must be the complete path of X509 certificate in the client computer. The certificate must be installed in the computer.
- <Payload Format>: Format of the message sent to the Broker. By default, the payload is set to follow JSON/SparkplugB format.
NOTE
One of the easiest ways to install the certificate on client computer is to use the wizard to import the certificates is through the "Internet Options" to import the certificate in the "Trusted Root Certification Authorities”. You need to import the certificate in DER format.
Station Examples
URL = CustomHub-MQTT.azure-devices.net
Port = 8883
Client ID = MQTT_Device
Username = CustomHub-MQTT.azure-devices.net/ MQTT_Device
Password = SharedAccessSignature sr=CustomHub-MQTT.azure devices.net&sig=ygIt%2FG8fIFAXhUwGXBlm6WKDK5IhbmVHkUs4atsbXFU%3D&skn=iothubowner&se=1612 031715
Ssl Protocol = <TLS>
X059 Certificate =
Payload Format = JSON/SparkplugB
For more information about how to set up a connection with Azure IoT Hub and find the required parameters, see the appendix. <<<<. please note there is no appendix in this article, so should we remove this info? >>>>
Points Configuration
The MQTT and Azure protocol supports Write Commands only.
Address
The Address syntax is: [Payload] : <Group > ; <Node> ; <Device> ;
Where:
- [Payload] = A fixed parameter that assists the user in understanding that the address configuration (group_id, edge_node_id and device_id) are the user-defined parameters in the Payload structure (similar to MQTT + SparkplugB protocol).
- <Group> = Provides a logical grouping of Edge Node’s.
- <Node> identifies ID of Edge Node.
- <DeviceId> identifies ID of Device from Edge Node. This field can be empty while accessing main Egde Node.
E.g.: Payload:GroupID;NodeID;DeviceID;
Payload:AzureGroup;Factory1;Motor
Troubleshoot
This section details some errors you might see in your connection to Azure IoT Hub via MQTT protocol and its possible causes.
Error: Exception connecting to the broker
If you see this message on the Trace Window Logs (with modules Debug and Devices enabled), check the port number parameter on Devices → Nodes → PrimaryStation.
Device.Node.Status = -1
If you get this error code on Devices.Node.<NodeName>.Status, check if the URL defined on Devices → Nodes → PrimaryStation is correct.
Error Connecting to Broker. Status: 5
If you see this message on the Trace Window Logs (with modules Debug and Devices enabled)check the following parameters on Devices → Nodes → PrimaryStation:
- Username
- ClientID
MQTT driver connection lost: System.EventArgs
If you see this message on the Trace Window Logs (with modules Debug and Devices enabled), check the QoS setting on Devices → Nodes → PrimaryStation. As stated in a previous section, IoT Hub will automatically disconnect your client if the QoS value is 2 (Exactly Once).
Another reason is that someone else tried to connect to your IoT Device using the same ClientID. IoT Hub only supports one active MQTT connection per device. Any new MQTT connection on behalf of the same device ID causes IoT Hub to drop the existing connection.
Driver Revision History
MQTTAzure Revision History | |
---|---|
Version | Notes |
1.0.0.3 | Initial release on new documentation standards. |