You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Specify re-connect handling for different protocols #212 (#226)
* Specify re-connect handling for different protocols #212
* OFT tags and clarifications
* Small corrections
* resubscribe suggestion accepted
Co-authored-by: Kai Hudalla <[email protected]>
* Removed unclear reconnect specification. Use only simple exponential backoff
---------
Co-authored-by: Kai Hudalla <[email protected]>
To establish an MQTT connection to a broker it *MUST* be possible for a UTransport to configure the `cleanSession` and `sessionExpiry` settings.
244
+
245
+
Those values have some important consequences summarized shortly:
246
+
247
+
[cols="1,1,1"]
248
+
|===
249
+
| cleanSession | sessionExpiry | Consequence
250
+
| true | 0 | Previous session data is deleted and state like messages, subscribtions etc. is lost if UTransport gets disconnected
251
+
| true | t>0 | Previous session data is deleted and new session will buffer data for time `t` if connection is lost
252
+
| false | t | Previous session including subscribtions, unreceived messages etc. is resumed and session will buffer data for time `t` if connection is lost
253
+
|===
254
+
255
+
Using a UTransport from the cloud side to connect to an MQTT broker we recommend to use `cleanSession=true` and `sessionExpiry=0` because we assume that there will always be at least one UTransport connected from the cloud which can handle messages so there is no need for buffering.
256
+
257
+
Establishing an mqtt5 UTransport from a device there is no general recommendation. Using `cleanSession=true` and `sessionExpiry=0` might be best for scaling since it reduces the load on the MQTT broker. Doing this one needs to take special care for offline devices. Using `cleanSession=true` and `sessionExpiry=t` might stress the broker but the broker helps when dealing with offline devices.
If a connection is lost, the UTransport *MUST* try to reconnect to the MQTT broker. If on successfull reconnect the broker sends the `sessionPresent=false` flag, the UTransport *MUST* re-subscribe to all previously subscribed topics.
0 commit comments