IOT-MQTT protocol - Control packets -UNSUBSCRIBE

3.10 unsubscribe - unsubscribe topics

UNSUBSCRIBE client sends a packet to the server in order to unsubscribe from a topic.

3.10.1 Fixed title

FIG 3.28 - UNSUBSCRIBE fixed packet header

Place

7

6

5

4

3

2

1

0

Byte 1

MQTT control packet type (10)

reserved

 

1

0

1

0

0

0

1

0

Byte 2

The remaining length

 UNSUBSCRIBE control packet header of a fixed 3,2,1 and 0 bit is reserved and must be set to 0, 0 and 0, respectively. The server must be treated as any other value malformed and network connections turned off  [the MQTT-3.10.1-1] .

The remaining length field

This is a variable length header (2 bytes) plus the payload.

3.10.2 Varliable variable head

Variable header contains a packet identifier. Section 2.3.1 provides more information on packet identifier.

FIG 3.29 - UNSUBSCRIBE packet header variables

Place

7

6

Fives

4

3

2

1

0

Byte 1

MSB packet identifier

Byte 2

LSB packet identifier

3.10.3 Payload Payload

UNSUBSCRIBE payload packet containing the client wishes to cancel a topic filter the list of subscriptions. Topic filter UNSUBSCRIBE packet must be UTF-8 encoded string defined in Section 1.5.3, continuous packing [the MQTT-3.10.3-1] .

UNSUBSCRIBE payload packet must contain at least one topic filter. UNSUBSCRIBE no payload data packets are protocol violations  [the MQTT-3.10.3-2] . About handling errors, see Section 4.8.

 

3.10.3.1 exemplary payload of the nonstandard

FIG nonstandard 3.30 payload byte format example shown in Table in 3.7 with the reference UNSUBSCRIBE packet payload briefly described - a non-canonical exemplary payload .

Table 3.7 - Example payloads nonstandard

Theme Filters

“A / B”

Theme Filters

"CD"

Figure 3.30 - payload bytes exemplary non-canonical format

 

description

7

6

5

4

3

2

1

0

Theme Filters

Byte 1

Length MSB (0)

0

0

0

0

0

0

0

0

Byte 2

The length of the LSB (3)

0

0

0

0

0

0

1

1

Byte 3

'a'(0x61)

0

1

1

0

0

0

0

1

Byte 4

'/'(0x2F)

0

0

1

0

1

1

1

1

Byte 5

'b'(0x62)

0

1

1

0

0

0

1

0

Theme Filters

Byte 6

Length MSB (0)

0

0

0

0

0

0

0

0

Byte 7

The length of the LSB (3)

0

0

0

0

0

0

1

1

8 bytes

'c'(0x63)

0

1

1

0

0

0

1

1

Byte 9

'/'(0x2F)

0

0

1

0

1

1

1

1

Byte 10

'd'(0x64)

0

1

1

0

0

1

0

0

3.10.4 Response response

Must (whether or not they contain wildcards) client and server to save a topic filter set-by-topic filter character UNSUBSCRIBE compare the current data package provided. If any filters exact match, then deleting its own subscription, it would not happen to other treatment  [the MQTT-3.10.4-1]
 

If the server to delete subscriptions:

  • It must be stopped to add any new messages delivered to the client  [the MQTT-3.10.4-2] .
  • It must be done already started sending to the client  [MQTT-3.10.4-3]  any QoS 1, QoS 2 or message passing .
  • It can continue to provide cushioning of any existing message for delivery to the client.

UNSUBSUBCRIBE server must respond by sending a request packet UNSUBACK. UNSUBACK packets must have the packet UNSUBSCRIBE  [MQTT-3.10.4-4]  same packet identifier. Even without deleting topic subscriptions, the server must also use UNSUBACK  [the MQTT-3.10.4-5] be the response.

If the server receives a data packet comprising a plurality of topics UNSUBSCRIBE filters, it must process the data packet, if it has received a plurality UNSUBSCRIBE sequence of data packets, except that it only transmits a response UNSUBACK  [MQTT-3.10.4- 6]

Guess you like

Origin blog.csdn.net/leeahuamsg/article/details/93473302