Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Mosquitto » Mosquitto: 2.0.x Persistent Client Subscription info lost after mosquitto restart(Mosquitto: 2.0.x Persistent Client Subscription info lost after mosquitto restart)
Mosquitto: 2.0.x Persistent Client Subscription info lost after mosquitto restart [message #1861183] Tue, 26 September 2023 16:58 Go to next message
Pavan Kumar Ogirala is currently offline Pavan Kumar OgiralaFriend
Messages: 7
Registered: September 2023
Junior Member
Dear Team,

This is my first post in the forum.

I am upgrading mosquitto in one of my projects from 1.6.12-4 to 2.0.1x series and was struck with one of the strange issues as described below.

Setup Details:
I have a client ABCD acting as a publisher of Topic A.
Configuration Clean Session as True,
Messages sent with QOS 1 )

I have a client PQRS acting as a subscriber of Topic A.
Clean Session False,
QOS1

Behavior with 1.6.12-4
1) When PQRS( which is acting as subscriber) disconnects, mosquito stores all the messages that are sent by client ABCD (which is acting as publisher) in the mosquitto.db as subscriber to the message is not yet finished reading the message.

2) With PQRS in disconnection state if the broker is restarted the subscription information of client PQRS is found to be still remembered as the new messages from ABCD continued to be accumulated/stored in the mosquitto.db.


Behavior with 2.0.1x
1) same as 1.6.12-4

2) With PQRS in disconnection state if the broker is restarted the subscription information of client PQRS is found to be lost and the new messages from ABCD are found to be acknowledged to client ABCD but are not stored in the mosquitto.db.

Reference:
This behavior is found to be not in line with definition of persistent client
"On connection, a client sets the "clean session" flag, which is sometimes also known as the "clean start" flag. If clean session is set to false, then the connection is treated as durable. This means that when the client disconnects, any subscriptions it has will remain and any subsequent QoS 1 or 2 messages will be stored until it connects again in the future. "

Question
Assuming that there is a behavioral difference between the 1.6.12-4 and 2.0.1x. I request you to please suggest if there is an additional setting that would make it work like before or if it is a known issue in 2.0.1x.

I have attached the mosquitto.conf files with this attachment.
The persistence is enabled in the configuration & persistent client expiry is set as 1 Year which should ideally mean the information should be retained.

Please help me in this regard.

Thanks and Regards,

[Updated on: Wed, 27 September 2023 06:13]

Report message to a moderator

Re: Mosquitto: 2.0.x Persistent Client Subscription info lost after mosquitto restart [message #1861190 is a reply to message #1861183] Wed, 27 September 2023 17:19 Go to previous messageGo to next message
Pavan Kumar Ogirala is currently offline Pavan Kumar OgiralaFriend
Messages: 7
Registered: September 2023
Junior Member
Added additional information:

ModulesStartAlongWithMosquitto.log
Alll the modules started together.
In this case when the pqrs client dropped out with mosquitto broker not restarting again the packets are stored in mosquitto.db

ModulesAlreadyRunningbeforeMosquitto.log
The pqrs subscribed to the mosquito in past and later the mosquitto broker was restarted.
In this case if pqrs connects back to mosquito broker the already accumulated messages are published to pqrs but if pqrs drops out later there is no new accumulation. For the broker to persist messages it needs to get a subscribe request after every restart.
Re: Mosquitto: 2.0.x Persistent Client Subscription info lost after mosquitto restart [message #1861205 is a reply to message #1861183] Fri, 29 September 2023 00:02 Go to previous messageGo to next message
Roger Light is currently offline Roger LightFriend
Messages: 90
Registered: September 2013
Member
Hello,

Your config looks fine, and I can say that I do not see the behaviour that you are seeing - it works as expected. Are you definitely using the same parameters in both test cases, and not missing a session-expiry-interval if you are using MQTT v5.0, for example?

Regards,

Roger
Re: Mosquitto: 2.0.x Persistent Client Subscription info lost after mosquitto restart [message #1861266 is a reply to message #1861205] Tue, 03 October 2023 09:25 Go to previous messageGo to next message
Pavan Kumar Ogirala is currently offline Pavan Kumar OgiralaFriend
Messages: 7
Registered: September 2023
Junior Member
Thank you for taking time in duplicating the bug. I am back from holidays today. I will try to create a minimalistic reproduction procedure and get back.
Re: Mosquitto: 2.0.x Persistent Client Subscription info lost after mosquitto restart [message #1861272 is a reply to message #1861266] Tue, 03 October 2023 14:15 Go to previous messageGo to next message
Pavan Kumar Ogirala is currently offline Pavan Kumar OgiralaFriend
Messages: 7
Registered: September 2023
Junior Member
Was unable to duplicate the bug with minimalistic duplication procedure. Would dig into further what step is causing the issue to occur and would post here.
Re: Mosquitto: 2.0.x Persistent Client Subscription info lost after mosquitto restart [message #1861300 is a reply to message #1861205] Wed, 04 October 2023 13:59 Go to previous messageGo to next message
Pavan Kumar Ogirala is currently offline Pavan Kumar OgiralaFriend
Messages: 7
Registered: September 2023
Junior Member
Hello Roger,

I am using Mosquito 3.x

In my specific setup. I noticed that when mosquitto is running inside a container if a reload configuration is done there is an issue in the mentioned sequence.

1) Mosquitto starts running
2) Subscriber subscribes to TopicA
3) Publisher publishes to Topic A, acknowledged by Mosquitto and received by Subscriber,
4) Disconnected subscriber
5) Restarted the mosquitto
6) Sent SIGHUP to the mosquitto after it started
7) Now if I publish to Topic A then it is not persited though it is acknowledges by the broker.

For the purpose of a simplistic duplication procedure, I created the same steps and discovered that step 6 seems to be causing some issue when running in the container. But, If I run the same outside the docker on a Linux host there is no issue.

I am further investigating this. But if you have any clue let me know.

Regards,
Pavan
Re: Mosquitto: 2.0.x Persistent Client Subscription info lost after mosquitto restart [message #1861337 is a reply to message #1861300] Fri, 06 October 2023 13:39 Go to previous messageGo to next message
Pavan Kumar Ogirala is currently offline Pavan Kumar OgiralaFriend
Messages: 7
Registered: September 2023
Junior Member
Hello Roger,

After some debugging, I was able to find a clue to the issue

The ACL information seems to be loaded by Mosquitto correctly only at Powerup.

Even when there is no change in ACL, If ACL is used with anonymous as false , If a reload signal is given then the subscribed client/topic information that was inactive seems to be impacted.

I had to change anonymous as true and remove the password file to work correctly.

Is there any issue in this area of Mosquitto?

I noticed that this behavior is the same across 1.6 & 2.0.x though my initial impression was that this is an issue with 2.0.x only.

I would duplicate the issue with mosquitto_sub & mosquitto_pub instead of my client and create a simple procedure on Monday in this area.

Regards,
Pavan
Duplication Procedure of bug with subscriptions not honoured with SIGHUP [message #1861583 is a reply to message #1861337] Fri, 20 October 2023 07:55 Go to previous message
Pavan Kumar Ogirala is currently offline Pavan Kumar OgiralaFriend
Messages: 7
Registered: September 2023
Junior Member
Hello Everyone,

Please find the simplistic duplication procedure using mosquitto_sub, mosquitto_pub and mosquito.
The script runs the broker, subscriber and publisher and restarts them in a timely fashion to create the bug.
1) Sets up the environment, files
2) Brings up broker and subscriber
3) publishes a message
4) kills the subscriber
5) Kills the broker
6) Setup broker again
7) publishes a message
8) SIGHUP broker
9) Publishes around 4 messages
10) Setup subscriber
11) Kills broker and subscriber

The messages which are expected to be received by the subscriber after it changes its state from inactive to active are lost if the SIGHUP message is given to broker. We can notice that neither subscriber received the messages nor they are stored in the db.
If the step 8 is skipped then we notice that there is no issue.



Regards,
Pavan
Previous Topic:Could any help with acl file settings?
Next Topic:closed noob mosquitto installation on armbian question
Goto Forum:
  


Current Time: Fri May 03 02:35:16 GMT 2024

Powered by FUDForum. Page generated in 0.04581 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top