CONNACK
Acknowledge Connection Request
This message is the response from the broker to a client making
a CONNECT request.
Fixed Header
See the Fixed Header section for more information,
| 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.
Variable Header
The CONNACK messsage carries two fields in the Variable Header:
-
Response to the Topic Name Compression (TNCOMP) flag
-
Connect request return code
See Variable Header section for more
information.
TNCOMP Response flag
This response makes the definitive statement on whether or not compression
of Topic Names will be allowed. If the CONNECT message has TNCOMP set to
0, then the response may not set it to 1. However, if the client requested
compression capability, the broker may reject the request and set the flag
to 0 in the response.
Note that at this version of the protocol, the flag is always 0 anyway,
so this is an academic point.
Connect return code
The possible values of the one byte unsigned return code are:
| 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 |
One of the reasons for a return code of 2 (identifier rejected) is that
it may be more than 23 characters long. The unique client identifier must
be 1-23 characters long. See the CONNECT section
for more information.
The format of the Variable Header is thus:
| |
Description |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
| Topic Name Compression Response |
| byte 1 |
TNCOMP
Response |
x
|
x
|
x
|
x
|
x
|
x
|
x
|
0
|
| Connect Return Code |
| byte 2 |
Return Code |
|
|
|
|
|
|
|
|
Payload
NONE
Discussion
-
ASC on CONNACK
-
In some future version of the protocol, we may also require a more
functional "Connect Acknowledge" (CONNACK) response, which contains a return
code from the Connect request. The currently anticipated values of this
return code would be:
-
Success
-
Authentication Required,
-
Authentication Refused,
-
Connection Refused (i.e. connection got through, but service unavailable
at present).
-
In the current version of the protocol, the client would continue to attempt
connections until a simple acknowledgement was received.
-
Comment
-
A Return Code field is a valuable addition. It is included in this version,
with scope for future expansion as required.
BACK to index
Last Modified: 22-Oct-99