MQTTv5 Connect and Connack Messages -Overview

mqttv5-connectThe MQTT CONNECT and response messages (CONNACK) have been greatly enhanced in MQTTv5 with the addition of the properties field.

This allows for a large increase in the information that can be exchanged on connection establishment compared to MQTT v3.11.

The properties field can be found in both the CONNECT and CONNACK , DISCONNECT and other messages.

The purpose of this tutorial is to provide an overview of the CONNECT message in MQTTv5 and a quick Comparison with MQTT v3.11.



The Connect Packet v3.11 and v5

The table below shows the differences between CONNECT messages in version MQTT 3.11 and MQTT v5:

Information Sent in The Connect Packet

MQTTv3.11 MQTTv5
Control Packet Type Control Packet Type
Protocol Name and Version Protocol Name and Version
Connect Flags Connect Flags
Keep Alive Keep Alive
Properties
Connect Payload Connect Payload

As you can see in the table above the messages are more or less identical with the exception of the properties field.

This field has been added to various messages including the CONNECT and CONNACK messages as well as the DISCONNECT messages.

Because of the the amount of information that can be sent in the CONNECT message I have just listed the fields available. A detailed description is available in the actual specification.

1.Control Packet Type
2.Protocol Name and Version

3. Sent Using Flags

Clean Start
Will Flag
Will QoS
Will Retain -New in MQTTv5
User Name Flag
Password Flag
Keep Alive

4. Sent Using Connect Properties

Session Expiry Interval
Receive Maximum
Maximum Packet Size
Topic Alias Maximum
Request Response Information
Request Problem Information
User Property
Authentication Method
Authentication Data

5. Sent In Payload – Note: Listed in order sent

Client Identifier ( ClientID )

Will Properties

Will Property length
Will Delay Interval
Payload Format Indicator
Message Expiry Interval
Content Type
Response Topic
Correlation Data
User Property

Will Topic
Will Payload
User Name
Password

The Connection Message will be acknowledged

Information Sent in Connack

Using Flags

Session Present
Connect Reason Code

Sent In the Connack Properties

Session Expiry Interval
Receive Maximum
Maximum QoS
Retain Available
Maximum Packet Size
Assigned Client Identifier
Topic Alias Maximum
Reason String
User Property
Wildcard Subscription Available
Subscription Identifiers Available
Shared Subscription Available
Server Keep Alive
Response Information
Authentication Methods
Authentication Data

Important Connection Properties

Maximum Packet Size

This is used to restrict the size of messages that the server can send to the client.

Topic Alias Maximum

Limits the number of topic aliases that the client will hold.

Request Response Information

This is used to request the server to send response information the the CONNACK packet.

Request Problem Information

Used to request reason codes in case of connection failure.

User Property

Another important addition that allows applications to send user data as key value pairs.

Authentication Method

Used to indicate the type of authentication used. This means other authentication methods are now available other than user name and password in MQTTv3.11

Authentication Data

Contents depend on the method set above.

Important CONNACK Properties

The server can now provide capability information to the client in the CONNACK message as well as reason codes useful in failed connections.

Examples:

Maximum QOS -Maximum QOS that the server will accept
Maximum Packet Size – Maximum packet size the server will accept.

Summary

The information send in the connection message and the response has increased greatly over that in MQTT v3.11 due to to addition of the properties field.

From this overview I sure you can appreciate the increased level of control available in these new features.

For example it is possible now to know in advance the maximum packet size the server wil except rather than to simply having the message discarded without notification.

Please rate? And use Comments to let me know more
[Total: 1    Average: 3/5]

Leave a Reply

Your email address will not be published. Required fields are marked *