The CONNACK message is the message sent by the broker in response to a CONNECT request from a client.
The fixed header format is shown in the table below.
bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
byte 1 | Message type (2) | DUP flag | QoS flags | RETAIN | ||||
0 | 0 | 1 | 0 | x | x | x | x | |
byte 2 | Remaining Length (2) | |||||||
0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
The DUP, QoS and RETAIN flags are not used in the CONNACK message.
The variable header format is shown in the table below.
Description | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |
---|---|---|---|---|---|---|---|---|---|
Topic Name Compression Response | |||||||||
byte 1 | Reserved values. Not used. | x | x | x | x | x | x | x | x |
Connect Return Code | |||||||||
byte 2 | Return Code |
The values for the one byte unsigned Connect return code field are shown in the table below.
Enumeration | HEX | Meaning |
---|---|---|
0 | 0x00 | Connection Accepted |
1 | 0x01 | Connection Refused: unacceptable protocol version |
2 | 0x02 | Connection Refused: identifier rejected |
3 | 0x03 | Connection Refused: broker unavailable |
4-255 | Reserved for future use |
Return code 2 (identifier rejected) is sent if the unique client identifier is not between 1 and 23 characters in length.