Connect

After a Network Connection is established by a Client to a Server, the first Packet sent from the Client to the Server MUST be a CONNECT Packet.

A Client can only send the CONNECT Packet once over a Network Connection. The Server MUST process a second CONNECT Packet sent from a Client as a protocol violation and disconnect the Client.

The payload contains one or more encoded fields. They specify a unique Client identifier for the Client, a Will topic, Will Message, User Name and Password. All but the Client identifier are optional and their presence is determined based on flags in the variable header.

Members

Variables

clientIdentifier
string clientIdentifier;

Client Identifier

flags
ConnectFlags flags;

The Connect Flags byte contains a number of parameters specifying the behavior of the MQTT connection. It also indicates the presence or absence of fields in the payload.

header
FixedHeader header;
Undocumented in source.
keepAlive
ushort keepAlive;

The Keep Alive is a time interval measured in seconds. Expressed as a 16-bit word, it is the maximum time interval that is permitted to elapse between the point at which the Client finishes transmitting one Control Packet and the point it starts sending the next. It is the responsibility of the Client to ensure that the interval between Control Packets being sent does not exceed the Keep Alive value. In the absence of sending any other Control Packets, the Client MUST send a PINGREQ Packet.

password
string password;

Password

protocolLevel
ubyte protocolLevel;

The 8 bit unsigned value that represents the revision level of the protocol used by the Client. The value of the Protocol Level field for the version 3.1.1 of the protocol is 4 (0x04).

protocolName
string protocolName;

The Protocol Name is a UTF-8 encoded string that represents the protocol name “MQTT”

userName
string userName;

User Name

willMessage
string willMessage;

Will Message

willTopic
string willTopic;

Will Topic

Meta