Open JuliusFruitfly opened 2 weeks ago
It's a good shout - we always re-subscribe on reconnect.
The problem with only doing that when cleanSession=true
is that if the broker is not persisting state, if the broker restarts, then it'll lose the session and no messages will be received by OT until it explicitly resubscribes. OT has no way of knowing when it reconnects whether or not a broker is holding an existing session, hence we always subscribe.
Could have it as a config setting for people who explicitly want to turn this behaviour off?
Andrew,
I think this problem is fixed in MQTT 3.1.1. The CONNACK has a 'session present' flag which is only set if you have connected to a valid, pre-existing session - so no subscribes necessary .
No extra configuration is required because the flag will only ever be set if 'mqttProtocolLevel' is set to 4.
This will only ever be a issue if you decide to change the default for mqttProtocolLevel in the future
Thanks
On Sat, 23 Nov 2024 at 19:20, Andrew Rowson @.***> wrote:
It's a good shout - we always re-subscribe on reconnect.
The problem with only doing that when cleanSession=true is that if the broker is not persisting state, if the broker restarts, then it'll lose the session and no messages will be received by OT until it explicitly resubscribes. OT has no way of knowing when it reconnects whether or not a broker is holding an existing session, hence we always subscribe.
Could have it as a config setting for people who explicitly want to turn this behaviour off?
— Reply to this email directly, view it on GitHub https://github.com/owntracks/android/issues/1912#issuecomment-2495627299, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARWEFQEAWCCIE5EIKNIPOYD2CDIPVAVCNFSM6AAAAABRW4WWMCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJVGYZDOMRZHE . You are receiving this because you authored the thread.Message ID: @.***>
--
Aha, excellent. Let me tinker.
Owntracks seems to re-issue subscriptions for a persistent mqtt session even when the protocol version is set to 4 (3.1.1) and the 'session present' flag is set in the CONNACK
This is a shame as it generates a lot of traffic on an unreliable connection
Thanks.