Skip to main content
2

CONNACK

0x20Server to Client

Fixed header flags: 0000 – all flags reserved

CONNACK is the broker's response to CONNECT. It carries a reason code (0x00 = success) and a Session Present flag indicating whether the broker has an existing session for this client. In MQTT 5.0, it also carries server capabilities: Maximum QoS, Retain Available, Maximum Packet Size, Assigned Client Identifier, and more.

Details

CONNACK acknowledges the CONNECT packet. The variable header contains:

Connect Acknowledge Flags: bit 0 = Session Present (1 if broker restored an existing session) Connect Reason Code (MQTT 5.0) / Return Code (MQTT 3.1.1): 0x00 = Success 0x80 = Unspecified error (5.0) 0x81 = Malformed packet 0x82 = Protocol error 0x84 = Unsupported Protocol Version 0x85 = Client Identifier not valid 0x86 = Bad User Name or Password 0x87 = Not Authorized 0x88 = Server Unavailable 0x89 = Server Busy 0x8A = Banned 0x9C = Use Another Server 0x9D = Server Moved 0x97 = Quota Exceeded

MQTT 5.0 properties in CONNACK let the broker advertise its capabilities to the client, including Maximum QoS supported, whether Retain is available, Maximum Packet Size, and Topic Alias Maximum. Clients must respect these limits.

Fixed Header

FieldValue
Packet type (bits 7–4)2 (0010₂)
First byte (hex)0x20
Flags (bits 3–0)0000 – all flags reserved
QoS bits applyNo
Directionserver-to-client
Added inMQTT 3.1

See Also