Android Question MQTT and persistence. QOS2

JakeBullet70

Well-Known Member
Licensed User
Longtime User

Here is a question on MQTT persistence. QOS2

I have my b4a shopping list app and 3 family members are using it and it is working fine so far. We use MQTT and the QoS2 so on or offline everybody syncs fine. No problems. Yesterday one of the phones died. So as I understand it, the MQTT messages are still going to be stored for the dead phone?

I have been searching the internet for the last hour trying to find a way to tell MQTT to stop storing messages for a particular client and have come up with nothing.

So any ideas?
 

JakeBullet70

Well-Known Member
Licensed User
Longtime User
After I wrote this it sort of hit me... I need to store the last time a client was online and if after a certain amount of time passes by if they NEVER reappear then I need to unsubscribe for them.

Sound about right?
 
Upvote 0

coslad

Well-Known Member
Licensed User
Longtime User
Erel you wrong , persistent message are saved into the broker storage until they are confirmed from the client .

http://www.hivemq.com/blog/mqtt-essentials-part-7-persistent-session-queuing-messages

From that page :


How long are messages stored on the broker ?
A often asked question is how long is a session stored on the broker. The easy answer is until the clients comes back online and receives the message. But what happens if a client does not come online for a long time? The constraint for storing messages is often the memory limit of the operating system. There is no standard way on what to do in this scenario. It totally depends on the use case. In HiveMQ we will provide a possibility to manipulate queued message and purge them.
 
Last edited:
Upvote 0

rboeck

Well-Known Member
Licensed User
Longtime User
What i miss is the feature, to see if a persistent session is waiting. In this situation i dont need to subscribe, because the last session is continued, if there is no session waiting, i have to subscripe for my messages. Can you explain the possibilities with JavaObject and MQTT client?
 
Upvote 0

rboeck

Well-Known Member
Licensed User
Longtime User
But we can use:
B4X:
Dim mo As MqttConnectOptions
mo.Initialize(User, Password)
mo.CleanSession=False
Is there a difference?
 
Upvote 0

rboeck

Well-Known Member
Licensed User
Longtime User
Replay to #7
What makes the difference when i use a pending session? I currently try to make an synchronisation based on mqtt. I publish json files, the topic contains the timestamp.
When i subscribe my topics, i get all messages from the beginning, even when i have sent them with QOS2. Only when i dont subscribe, i am in the last session and get exactly the messages i have to get. But then it could come to the situation, that i client looses completly this session, so i have to subscribe for new.
When i would see, if a session is waiting, i could use it, when no session is waiting, i could subscribe it new.
Because of the timestamps i can currently handle the situation, but i think, that the concept of mqtt with persistent sessions can only realized perfect.
Maybe someone knows, why i get all messages, even with QOS2, when i subscribe new. My client id is also the same.
 
Upvote 0

JakeBullet70

Well-Known Member
Licensed User
Longtime User
What makes the difference when i use a pending session? I currently try to make an synchronisation based on mqtt. I publish json files, the topic contains the timestamp.
When i subscribe my topics, i get all messages from the beginning, even when i have sent them with QOS2. Only when i dont subscribe, i am in the last session and get exactly the messages i have to get. But then it could come to the situation, that i client looses completly this session, so i have to subscribe for new.
When i would see, if a session is waiting, i could use it, when no session is waiting, i could subscribe it new.
Because of the timestamps i can currently handle the situation, but i think, that the concept of mqtt with persistent sessions can only realized perfect.
Maybe someone knows, why i get all messages, even with QOS2, when i subscribe new. My client id is also the same.

Mine works fine with QOS2. What broker are you using? Erel's or?
 
Upvote 0

JakeBullet70

Well-Known Member
Licensed User
Longtime User
My GUT feeling says it is your config. But have you tried another broker?
You can use the public mosquitto.org test : tcp://test.mosquitto.org:1883

Or I have a private mosquitto broker if you would rather test there. If so let me know and I will PM you with details.
FYI: I am the only one on my MQTT broker. It is not Erel's but a full install of mosquitto.
 
Upvote 0

rboeck

Well-Known Member
Licensed User
Longtime User
Thanks for your ideas; currently i have to check everything an make step by step. Later i will try another provider.
Thanks
Reinhard
 
Upvote 0
Top