OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

mqtt message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: [OASIS Issue Tracker] (MQTT-249) Add expiry capabilities to MQTT.


     [ https://issues.oasis-open.org/browse/MQTT-249?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrew Banks updated MQTT-249:
------------------------------

    Proposal: 
1) Expiry of Session state, update the CONNECT packet variable header to replace the Clean Session flag with a Clean Start flag in the same position in the Connect flags and add a separate Session Expiry value.
   
   - Section 3.1.2.3 Connect Flags The Clean session bit (1) becomes the CleanStart Bit..
   - 3.1.2.4 Clean Start.
Position: bit 1 of the Connect Flags byte.

This bit specifies whether the Session state when a connection is made, see section Optional Session State Expiry interval for a definition of the Session State.


   - After 3.1.2.10 Keep Alive add:

     3.1.2.11 Optional CONNECT values.
     The Remaining Length of optional Identifier/Value pairs in the
     CONNECT Packet variable header. The remaining Length or the
     variable header  does not include the bytes used to encode 
     the Remaining Length. A remaining length of zero indicates that there are no optional
     Identifier/Value pairs in the CONNECT packet.

     On receipt of an Identifier or Value, that is not defined below, 
     the receiver MUST close the network connection.

     3.1.2.12 Optional Session State Expiry interval.
    
     Byte  17 (0x11) Identifier of the Session Expiry Interval.
     Followed by the four byte Session Expiry interval, most significant byte first.

     The Client and Server can store Session State to enable reliable messaging to continue
     across a sequence of Network Connections.
     The Session Expiry is a time interval measured in seconds, expressed as a 32-bit word. 
     After a network disconnection and the Session Expiry interval has passed, 
     without a new connection being made the Client 
     and Server each delete the Session State they hold.
     If the Session State Expiry interval is absent 
     the Session State does not expire.
     If set to zero the session State is deleted immediately the Network connection is lost.
     
     If a new connection is made before the Session has expired, 
     the Server MUST resume communications with the Client based on state from the current 
     Session (as identified by the Client identifier). If there is no Session associated with 
     the Client identifier the Server MUST create a new Session. The Client and Server MUST 
     store the Session after the Client and Server are disconnected [MQTT-3.1.2-4]. 

     After the disconnection of a Session and before the session Expiry interval has passed,
     the Server MUST store further QoS 1 and QoS 2 messages that match any subscriptions
     that the client had at the time of disconnection as part of the Session state [MQTT-3.1.2-5]. 
     It MAY also store QoS 0 messages that meet the same criteria.
     State data associated with this Session MUST NOT be reused in any subsequent Session [MQTT-3.1.2-6].
 
     After the disconnection of a Session and after the Session Expiry Interval has passed,
     the Client and Server discard any Session State.
     A client with no clock SHOULD either set a Session Expiry of zero, or not set a Session Expiry.
     A server MAY avoid implementing Session Expiry greater than zero by not actually deleting the 
     Session state. 

     After reconnection the Session lasts as long as the Network Connection plus 
     the new Session Expiry interval.     
 
     The Session state in the Client consists of:
       QoS 1 and QoS 2 messages which have been sent to the Server, 
       but have not been completely acknowledged.
       QoS 2 messages which have been received from the Server, 
       but have not been completely acknowledged. 
       If the session is currently disconnected, 
       the time at which the Session State will be deleted.
 
      The Session state in the Server consists of:
        The existence of a Session, even if the rest of the Session state is empty.
        The Client’s subscriptions.
        QoS 1 and QoS 2 messages which have been sent to the Client, but have not been completely acknowledged.
        QoS 1 and QoS 2 messages pending transmission to the Client.
        QoS 2 messages which have been received from the Client, but have not been completely acknowledged.
        Optionally, QoS 0 messages pending transmission to the Client. 
        If the session is currently disconnected, 
        the time at which the Session State will be deleted.
 
     Retained messages do not form part of the Session state in the Server, 
     they MUST NOT be deleted when the Session ends [MQTT-3.1.2.7].
 
     See Section 4.1 for details and limitations of stored state.
 
     When the Session State expires the Client and Server need not process 
     the deletion of state atomically.
 
     Non normative comment
     To ensure consistent state in the event of a failure, 
     the Client should repeat its attempts to connect with a Session Expiry interval of 0,
     until it connects successfully.
 
     Non Normative comment
     Setting a Session Expiry interval of 0 is equivalent to setting CleanSession to 1 in the 
     MQTT Specification Version 3.1.1. 
     Setting no Session Expiry interval is equivalent to setting CleanSession to 0 in the 
     MQTT Specification Version 3.1.1. 

     Non normative comment
     Typically, a Client will always connect using the same Session Expiry interval.
     The choice will depend on the application. 
     A Client using Session Expiry set to 0 will not receive old 
     Application Messages and has to subscribe afresh to any topics 
     that it is interested in each time it connects. 
     A Client using a non zero Session Expiry will receive all QoS 1 or QoS 2 
     messages that were published while it was disconnected. 
     Hence, to ensure that you do not loose messages while disconnected, 
     use QoS 1 or QoS 2 with no Session Expiry or a Session Expiry greater than zero.

     Non normative comment
     When a Client connects with long Session Expiry, 
     it is requesting that the Server maintain its MQTT 
     session state after it disconnects for an extended period. 
     Clients should only connect with a long Session Expiry,
     if they intend to re connect to the Server at some later point in time. 
     When a Client has determined that it has no further use for the 
     session it should do a final connect with Session Expiry 0 
     and then disconnect.

     Non normative comment
     A Client might be connecting to a server using a network that provides
     intermittent connectivity. This Client can use a short Session Expiry
     so that it can re connect when the network is available again and continue
     reliable message delivery. If the client does not re connect, allowing the 
     Session State to expire, then application messages may be lost.

     Non normative comment
     If the client connects using this protocol, then re connects using 
     the MQTT V3.1.1 protocol using cleanSession=0 before the session has expired, 
     then the session state is kept indefinitely.
     
   - Update section 3.1.2.11  Variable header non normative example to show no 
     Clean Session flag and add Optional CONNECT values with a Session Expiry interval.

   - In CONNACK Replace 3.2.2.2 Session Present 

     Position: bit 0 of the Connect Acknowledge Flags. 

     If the Server accepts a connection with Session Expiry set to 0, 
     the Server MUST set Session Present to 0 in the CONNACK packet
     in addition to setting a zero return code in the CONNACK packet [MQTT-3.2.2-1].

     If the Server accepts a connection with non zero Session Expiry, 
     the value set in Session Present depends on whether the Server has 
     stored Session state for the supplied client ID. 
     If the Server has stored Session state, 
     it MUST set Session Present to 1 in the CONNACK packet [MQTT-3.2.2-2]. 
     If the Server does not have stored Session state, 
     it MUST set Session Present to 0 in the CONNACK packet. 
     This is in addition to setting a zero return code in the CONNACK packet [MQTT-3.2.2-3].

     The Session Present flag enables a Client to establish whether the Client and 
     Server have a consistent view about whether there is already stored Session state. 

     Once the initial setup of a Session is complete, 
     a Client with stored Session state will expect the Server 
     to maintain its stored Session state. 
     In the event that the value of Session Present received by the Client 
     from the Server is not as expected, 
     the Client can choose whether to proceed with the Session or to disconnect. 
     The Client can discard the Session state on both Client and Server by disconnecting, 
     connecting with Session Expiry set to zero and then disconnecting again. 

     If a server sends a CONNACK packet containing a non-zero return code 
     it MUST set Session Present to 0 [MQTT-3.2.2-4].

     Non normative comment
     The clock in the Client or Server may not be running for part of the time interval, 
     for instance because they are not running. This might cause the deletion of the state
     to be delayed. 

2) Update the description of the PUBLISH Packet to include the optional 
   Publication Expiry interval.
 
   - After 3.3.2.4 Optional Payload Format Indicator. add:

     3.3.2.5 Optional Publication Expiry interval.
     
     Byte  2 (0x02) Identifier of the Publication Expiry interval.
     Followed by the four byte Publication Expiry interval, most
     significant byte first.

     If absent, the publication does not expire. 
     If present the four byte value is the lifetime of the publication in seconds. 
     The server MUST attempt start delivery to a matching subscriber
     until at least this number of seconds has passed, or the session state is deleted.
     The PUBLISH packet sent to a client by the server MUST contain a Publication
     Expiry interval set to the received value minus the time that the publication has
     been waiting in the server. 
     
     See Section 4.1 for details and limitations of stored state.   

     The Server MAY avoid implementing publication expiry by passing the Publication 
     Expiry interval unchanged to any matching subscribers.

   - In section 4.3.3 QoS 2: Exactly once delivery, for the Sender add:

     MUST NOT apply Publication Expiry if a Publish Packet has been sent.

   - In section 4.3.3 QoS 2: Exactly once delivery, for the Receiver add:

     MUST NOT apply Publication Expiry until after PUBCOMP has been sent.


  was:
1) Expiry of Session state, update the CONNECT packet variable header to remove the 
   Clean Session flag and add a Session Expiry value.
   
   - Section 3.1.2.3 Connect Flags The Clean session bit (1) must be 0.
   - Remove 3.1.2.4 Clean Session.

   - After 3.1.2.10 Keep Alive add:

     3.1.2.11 Optional CONNECT values.
     The Remaining Length of optional Identifier/Value pairs in the CONNECT Packet
     variable header. The remaining Length or the variable header 
     does not include the bytes used to encode 
     the Remaining Length. A remaining length of zero indicates that there are no optional
     Identifier/Value pairs in the CONNECT packet.

     On receipt of an Identifier or Value, that is not defined below, 
     the receiver MUST close the network connection.

     3.1.2.12 Optional Session State Expiry interval.
    
     Byte  17 (0x11) Identifier of the Session Expiry Interval.
     Followed by the four byte Session Expiry interval, most significant byte first.

     The Client and Server can store Session State to enable reliable messaging to continue
     across a sequence of Network Connections.
     The Session Expiry is a time interval measured in seconds, expressed as a 32-bit word. 
     After a network disconnection and the Session Expiry interval has passed, 
     without a new connection being made the Client 
     and Server each delete the Session State they hold.
     If the Session State Expiry interval is absent 
     the Session State does not expire.
     If set to zero the session State is deleted immediately the Network connection is lost.
     
     If a new connection is made before the Session has expired, 
     the Server MUST resume communications with the Client based on state from the current 
     Session (as identified by the Client identifier). If there is no Session associated with 
     the Client identifier the Server MUST create a new Session. The Client and Server MUST 
     store the Session after the Client and Server are disconnected [MQTT-3.1.2-4]. 

     After the disconnection of a Session and before the session Expiry interval has passed,
     the Server MUST store further QoS 1 and QoS 2 messages that match any subscriptions
     that the client had at the time of disconnection as part of the Session state [MQTT-3.1.2-5]. 
     It MAY also store QoS 0 messages that meet the same criteria.
     State data associated with this Session MUST NOT be reused in any subsequent Session [MQTT-3.1.2-6].
 
     After the disconnection of a Session and after the Session Expiry Interval has passed,
     the Client and Server discard any Session State.
     A client with no clock SHOULD either set a Session Expiry of zero, or not set a Session Expiry.
     A server MAY avoid implementing Session Expiry greater than zero by not actually deleting the 
     Session state. 

     After reconnection the Session lasts as long as the Network Connection plus 
     the new Session Expiry interval.     
 
     The Session state in the Client consists of:
       QoS 1 and QoS 2 messages which have been sent to the Server, 
       but have not been completely acknowledged.
       QoS 2 messages which have been received from the Server, 
       but have not been completely acknowledged. 
       If the session is currently disconnected, 
       the time at which the Session State will be deleted.
 
      The Session state in the Server consists of:
        The existence of a Session, even if the rest of the Session state is empty.
        The Client’s subscriptions.
        QoS 1 and QoS 2 messages which have been sent to the Client, but have not been completely acknowledged.
        QoS 1 and QoS 2 messages pending transmission to the Client.
        QoS 2 messages which have been received from the Client, but have not been completely acknowledged.
        Optionally, QoS 0 messages pending transmission to the Client. 
        If the session is currently disconnected, 
        the time at which the Session State will be deleted.
 
     Retained messages do not form part of the Session state in the Server, 
     they MUST NOT be deleted when the Session ends [MQTT-3.1.2.7].
 
     See Section 4.1 for details and limitations of stored state.
 
     When the Session State expires the Client and Server need not process 
     the deletion of state atomically.
 
     Non normative comment
     To ensure consistent state in the event of a failure, 
     the Client should repeat its attempts to connect with a Session Expiry interval of 0,
     until it connects successfully.
 
     Non Normative comment
     Setting a Session Expiry interval of 0 is equivalent to setting CleanSession to 1 in the 
     MQTT Specification Version 3.1.1. 
     Setting no Session Expiry interval is equivalent to setting CleanSession to 0 in the 
     MQTT Specification Version 3.1.1. 

     Non normative comment
     Typically, a Client will always connect using the same Session Expiry interval.
     The choice will depend on the application. 
     A Client using Session Expiry set to 0 will not receive old 
     Application Messages and has to subscribe afresh to any topics 
     that it is interested in each time it connects. 
     A Client using a non zero Session Expiry will receive all QoS 1 or QoS 2 
     messages that were published while it was disconnected. 
     Hence, to ensure that you do not loose messages while disconnected, 
     use QoS 1 or QoS 2 with no Session Expiry or a Session Expiry greater than zero.

     Non normative comment
     When a Client connects with long Session Expiry, 
     it is requesting that the Server maintain its MQTT 
     session state after it disconnects for an extended period. 
     Clients should only connect with a long Session Expiry,
     if they intend to re connect to the Server at some later point in time. 
     When a Client has determined that it has no further use for the 
     session it should do a final connect with Session Expiry 0 
     and then disconnect.

     Non normative comment
     A Client might be connecting to a server using a network that provides
     intermittent connectivity. This Client can use a short Session Expiry
     so that it can re connect when the network is available again and continue
     reliable message delivery. If the client does not re connect, allowing the 
     Session State to expire, then application messages may be lost.

     Non normative comment
     If the client connects using this protocol, then re connects using 
     the MQTT V3.1.1 protocol using cleanSession=0 before the session has expired, 
     then the session state is kept indefinitely.
     
   - Update section 3.1.2.11  Variable header non normative example to show no 
     Clean Session flag and add Optional CONNECT values with a Session Expiry interval.

   - In CONNACK Replace 3.2.2.2 Session Present 

     Position: bit 0 of the Connect Acknowledge Flags. 

     If the Server accepts a connection with Session Expiry set to 0, 
     the Server MUST set Session Present to 0 in the CONNACK packet
     in addition to setting a zero return code in the CONNACK packet [MQTT-3.2.2-1].

     If the Server accepts a connection with non zero Session Expiry, 
     the value set in Session Present depends on whether the Server has 
     stored Session state for the supplied client ID. 
     If the Server has stored Session state, 
     it MUST set Session Present to 1 in the CONNACK packet [MQTT-3.2.2-2]. 
     If the Server does not have stored Session state, 
     it MUST set Session Present to 0 in the CONNACK packet. 
     This is in addition to setting a zero return code in the CONNACK packet [MQTT-3.2.2-3].

     The Session Present flag enables a Client to establish whether the Client and 
     Server have a consistent view about whether there is already stored Session state. 

     Once the initial setup of a Session is complete, 
     a Client with stored Session state will expect the Server 
     to maintain its stored Session state. 
     In the event that the value of Session Present received by the Client 
     from the Server is not as expected, 
     the Client can choose whether to proceed with the Session or to disconnect. 
     The Client can discard the Session state on both Client and Server by disconnecting, 
     connecting with Session Expiry set to zero and then disconnecting again. 

     If a server sends a CONNACK packet containing a non-zero return code 
     it MUST set Session Present to 0 [MQTT-3.2.2-4].

     Non normative comment
     The clock in the Client or Server may not be running for part of the time interval, 
     for instance because they are not running. This might cause the deletion of the state
     to be delayed. 

2) Update the description of the PUBLISH Packet to include the optional 
   Publication Expiry interval.
 
   - After 3.3.2.4 Optional Payload Format Indicator. add:

     3.3.2.5 Optional Publication Expiry interval.
     
     Byte  2 (0x02) Identifier of the Publication Expiry interval.
     Followed by the four byte Publication Expiry interval, most
     significant byte first.

     If absent, the publication does not expire. 
     If present the four byte value is the lifetime of the publication in seconds. 
     The server MUST attempt start delivery to a matching subscriber
     until at least this number of seconds has passed, or the session state is deleted.
     The PUBLISH packet sent to a client by the server MUST contain a Publication
     Expiry interval set to the received value minus the time that the publication has
     been waiting in the server. 
     
     See Section 4.1 for details and limitations of stored state.   

     The Server MAY avoid implementing publication expiry by passing the Publication 
     Expiry interval unchanged to any matching subscribers.

   - In section 4.3.3 QoS 2: Exactly once delivery, for the Sender add:

     MUST NOT apply Publication Expiry if a Publish Packet has been sent.

   - In section 4.3.3 QoS 2: Exactly once delivery, for the Receiver add:

     MUST NOT apply Publication Expiry until after PUBCOMP has been sent.



> Add expiry capabilities to MQTT.
> --------------------------------
>
>                 Key: MQTT-249
>                 URL: https://issues.oasis-open.org/browse/MQTT-249
>             Project: OASIS Message Queuing Telemetry Transport (MQTT) TC
>          Issue Type: Improvement
>          Components: futures
>    Affects Versions: 3.1.1
>            Reporter: Andrew Banks
>            Assignee: Andrew Banks
>
> MQTT has the ability to purge all of the session state on demand by using the clean session flag. This proposal is for a time based and more granular capability to clear up state.  
> Add capabilities to MQTT to allow for expiry of.
> 1) Messages.
> 2) Subscriptions.
> 3) All session state, for example if the client is disconnected for a time period then treat it as if it had connected with clean session true.  This is sometimes referred to as offline keep alive.



--
This message was sent by Atlassian JIRA
(v6.2.2#6258)


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]