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

Conversation

redboltz
Copy link
Owner

No description provided.

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].

---
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.
@codecov
Copy link

codecov bot commented Dec 18, 2020

Codecov Report

Merging #767 (a5d9118) into master (364be87) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #767      +/-   ##
==========================================
- Coverage   85.19%   85.19%   -0.01%     
==========================================
  Files          61       61              
  Lines        8694     8645      -49     
==========================================
- Hits         7407     7365      -42     
+ Misses       1287     1280       -7     

@redboltz redboltz merged commit abb4f52 into master Dec 18, 2020
@redboltz redboltz deleted the remove_client_side_session_expiry_timer branch December 18, 2020 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant