Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove client side session expiry timer #767

Merged
merged 2 commits into from
Dec 18, 2020

Commits on Dec 18, 2020

  1. Removed session expiry timer from client.

    I thought that the client needs to have session expiry timer to erase
    inflight messages. So I implemented the session expiry timer for the
    client.
    
    However, I found the following clause in the spec.
    
    ---
    
    https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901078
    
    If the Server accepts a connection with Clean Start set to 1, the Server
    MUST set Session Present to 0 in the CONNACK packet in addition to setting
    a 0x00 (Success) Reason Code in the CONNACK packet [MQTT-3.2.2-2].
    
    https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901048
    
    The Client can avoid implementing its own Session expiry and instead rely on
    the Session Present flag returned from the Server to determine if the Session
    had expired. If the Client does implement its own Session expiry, it needs to
    store the time at which the Session State will be deleted as part of its
    Session State.
    
    ---
    
    That means the client can remove the session expiry timer depends on
    broker side session existance that is reported by session_present flag
    on CONNACK packet.
    
    The spac also said that as follows. It is the session state mismatching
    between the client and the broker. If they have the timers individually,
    then it could happen. It is a kind of clock skew.
    
    Depending on session_present can automatically avoid this issue.
    So, I decided removing from session expiry timer from the client and use
    session_present flag to erase the inflight messages.
    It is a better design.
    
    ---
    https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901078
    
    If the Client does not have Session State and receives Session Present
    set to 1 it MUST close the Network Connection [MQTT-3.2.2-4]. If it
    wishes to restart with a new Session the Client can reconnect using
    Clean Start set to 1.
    
    If the Client does have Session State and receives Session Present set
    to 0 it MUST discard its Session State if it continues with the Network
    Connection [MQTT-3.2.2-5].
    
    ---
    redboltz committed Dec 18, 2020
    Configuration menu
    Copy the full SHA
    3b085ae View commit details
    Browse the repository at this point in the history
  2. Fixed offline publish test.

    The published messages during offline should be sent only if the session
    exists in the broker.
    If offline publish is sent after session has been expired is a protocol error.
    redboltz committed Dec 18, 2020
    Configuration menu
    Copy the full SHA
    a5d9118 View commit details
    Browse the repository at this point in the history