Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] MQTT-SN DISCONNECT message's Duration is optional.

Hi Tomoaki,

the MQTT-SN specification says (5.4.21):

"Duration: contains the value of the sleep timer; this field is optional and is included by a “sleeping” client that wants to go the “asleep” state, see Section 6.14 for further details."

"As with MQTT, the DISCONNECT message is sent by a client to indicate that it wants to close the connection. The gateway will acknowledge the receipt of that message by returning a DISCONNECT to the client. A server or gateway may also sends a DISCONNECT to a client, e.g. in case a gateway, due to an error, cannot map a received message to a client. Upon receiving such a DISCONNECT message, a client should try to setup the connection again by sending a CONNECT message to the gateway or server. In all these cases the DISCONNECT message does not contain the Duration field. 

A DISCONNECT message with a Duration field is sent by a client when it wants to go to the “asleep” state.  The receipt of this message is also acknowledged by the gateway by means of a DISCONNECT message (without a duration field)."

Does that answer your question?

The gateway does not have to support all functions to start with, or even to end with.  If you wanted to submit a work in progress for others to try out, test and review then that might be a good approach.



On 04/21/2016 10:33 AM, Tomoaki Yamaguchi wrote:
Hi All,

in MQTTSNPacket.c

 int MQTTSNSerialize_disconnect(unsigned char* buf, int buflen, int duration)

    ptr += MQTTSNPacket_encode(ptr, len); /* write length */
    writeChar(&ptr, MQTTSN_DISCONNECT);      /* write message type */

    if (duration >= 0)                <======
        writeInt(&ptr, duration);

if (duration >= 0)   should be   if (duration > 0) .
 what is the meaning of optional ?


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
Paho Project Lead; Committer on Mosquitto

Back to the top