Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] Embedded C Paho Client QoS2 bug

Hello,

I encountered a problem while implementing a MQTT client with CC3200 and Paho.
I wanted to develop a full client, with ability to publish messages with QoS 1, 2 or 3.

Publish with QoS 1 or 2 works great. But publishing with QoS 3 doesn't work.
I am able to see that PUBLISH message goes trough, and I am able to receive PUBREC from the broker.
But when sending PUBREL, broker finds an error and disconnects the client.
I used the MQTTSerialize_pubrel function to pack the message into buffer, and then simply send it to the broker.

After reading the MQTT protocol specification, I found the bug: header for the PUBREL message isn't generated properly.
Specification says: "Bits 3,2,1 and 0 of the fixed header in the PUBREL Control Packet are reserved and MUST be set to
876 0,0,1 and 0 respectively."
Paho's function MQTTSerialize_ack generates 0x60 fixed header for PUBREL, thus creating an error- it must be 0x62.
I changed header.bits.qos = 0; to header.bits.qos = 1, and after that it started working properly, and now I am able to publish message with any QoS.

If anyone else is having this problem, changing that one line solved it for me.

Thanks,
Sava



Back to the top