[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] Client Publications rejected / QoS error

Hi Mike,

the QoS is a parameter to the serialize publish call:

 * Serializes the supplied publish data into the supplied buffer, ready for sending
 * @param buf the buffer into which the packet will be serialized
 * @param buflen the length in bytes of the supplied buffer
 * @param dup integer - the MQTT dup flag
 * @param qos integer - the MQTT QoS value
 * @param retained integer - the MQTT retained flag
 * @param packetid integer - the MQTT packet identifier
 * @param topicName MQTTString - the MQTT topic in the publish
 * @param payload byte buffer - the MQTT publish payload
 * @param payloadlen integer - the length of the MQTT payload
 * @return the length of the serialized data. <= 0 indicates error
int MQTTSerialize_publish(unsigned char* buf, int buflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid,
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ MQTTString topicName, unsigned char* payload, int payloadlen)

You've set it to 3, which is not valid in MQTT - only 0, 1 or 2 are.


On 01/10/2018 09:38, Mike Maikaefer wrote:
Hi everyone,

I'm trying to implement a MQTT-client based on the embedded variant of Paho. This is what my code looks like (pseudocode of the relevant parts):

 Âstruct mqtt_inst_data Â*instData;
 ÂMQTTPacket_connectData Âdata="">
 ÂMQTTString       Âtopic=MQTTString_initializer;

 Â-> open TCP/IP connection here

 Âlen = MQTTSerialize_connect(buf,MAX_BUFLEN,&data); /* 1 */



 Âlen+=MQTTSerialize_publish(buf+len,MAX_BUFLEN-len,0,3,0,0,topic,(unsigned char*)payload,payloadlen); /* 2 */
 Âlen+=MQTTSerialize_disconnect(buf+len,MAX_BUFLEN-len); /* 3 */

 Â-> send data "buf" with length "len" here
 Â-> close TCP/IP connection

After doing this Mosquitto debug output comes with following error messages:

1538382438: New connection from on port 1883.
1538382446: New client connected from as C85B76DF5FF6 (c1, k60).
1538382446: No will message specified.
1538382446: Sending CONNACK to C85B76DF5FF6 (0, 0)
1538382446: Invalid QoS in PUBLISH from C85B76DF5FF6, disconnecting.
1538382446: Socket error on client C85B76DF5FF6, disconnecting.

Where/how do I have to set this QoS stuff exactly?ÂMQTTPacket_connectData has a sub-structureÂMQTTPacket_willOptions which itself contains a member "qos" - but what do I have to do with this structure exactly? Or is this error caused by some other problem?



paho-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Ian Craggs
icraggs@xxxxxxxxxx                 IBM United Kingdom
Eclipse Paho Project Lead & Mosquitto Committer