Configuration.decodeMQTT()
Description
Appends a decodeMQTT filter to the current pipeline layout.
A decodeMQTT filter decodes MQTT packets from a raw byte stream.
- INPUT - Data stream to decode MQTT packets from.
- OUTPUT - MQTT packets (Messages) decoded from the input Data stream.
After decoding, the output Message has:
- head
- type - Type of the packet such as "SUBSCRIBE" and "PUBLISH"
- qos - PUBLISH Quality of Service
- dup - Duplicate delivery of a PUBLISH packet
- retain - PUBLISH retained message flag
- Other properties defined in the specification
- body - Payload of a PUBLISH packet
Protocol level
By default, the decoder works in protocol level 4 (MQTT v3.1.1). When decoding MQTT packets sending to the broker, the first packet would be a CONNECT packet, which includes the protocol level being used. The decoder can then switch to the correct protocol level.
However, when decoding packets returning from the broker, there's no such information in the packets themselves, so you need to provide the correct protocol level by option protocolLevel in the options parameter. It can be a number, or a function that returns a number.
The following protocol levels are supported:
- When protocolLevel is 4, works in MQTT v3.1.1
- When protocolLevel is 5, works in MQTT v5.0
Syntax
pipy().pipeline().decodeMQTT()pipy().pipeline().decodeMQTT({protocolLevel})
Parameters
decodeMQTT()
The same Configuration object.