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
A client publish one message with length = 1024 bytes and qos = 1 every 1 second, meanwhile another client subscribe the same topic with the same qos level, and then write to mysql server.
step1: pull up the cable of publish-client for 30 minutes.
step2: reconnect the cable of the publish-client.
step3: wait 5 minutes to let publish-client to process(publish and republish the failed messages)
step4: check the saved datas of mysql server by the timestamp in each message's payload.
The conclusion is: mosquitto will save these published-failed-messages while network is broken, after the network reworks, mosquitto will republish these published-failed-messages, but maybe not all(it depends on the sum of bytes of all published-failed-messages or the number of all published-failed-messages, I guess).
So I looked into the source code of mosquitto, the flow of publishing is:
[exec mosquitto_publish()] --> [check the size of message] --> [if the size is valid, push_back to a mesages-linked-list].
In the net's loop, get the pointer of the first message from the list to publish, if publish success, remove it from list, and go to the next message; if failed, will not remove this message from this list.
You don't check the size of the current mesages-linked-list before exec push_back and the sum of bytes of all messages in this mesages-linked-list! This conflicted with my upper test. So, question one, why not to check?(if my upper analysis is right)
I want to add a feature into my client. If client publish failed with qos = 1 or 2, I will save them into local database, after network reworks, I'll republish and remove them from database manually.
But now it has some problems,
One: If publish failed with qos = 1, and after network reworks, both you and I will republish them, that is wasteful.
Two: If publish failed with qos = 2, and after network reworks, both you and I will republish them, this conflict with the definition of qos = 2.
So, my question two, is there a solution to stop your republish-action? (From my point, by removing from linked-list rather than still leaving them in linked-list when publish failed will solve this problem, and at the same time, this will be more friendly for developers.)
The text was updated successfully, but these errors were encountered:
I dit a test.
A client publish one message with length = 1024 bytes and qos = 1 every 1 second, meanwhile another client subscribe the same topic with the same qos level, and then write to mysql server.
step1: pull up the cable of publish-client for 30 minutes.
step2: reconnect the cable of the publish-client.
step3: wait 5 minutes to let publish-client to process(publish and republish the failed messages)
step4: check the saved datas of mysql server by the timestamp in each message's payload.
The conclusion is: mosquitto will save these published-failed-messages while network is broken, after the network reworks, mosquitto will republish these published-failed-messages, but maybe not all(it depends on the sum of bytes of all published-failed-messages or the number of all published-failed-messages, I guess).
So I looked into the source code of mosquitto, the flow of publishing is:
You don't check the size of the current mesages-linked-list before exec push_back and the sum of bytes of all messages in this mesages-linked-list! This conflicted with my upper test. So, question one, why not to check?(if my upper analysis is right)
I want to add a feature into my client. If client publish failed with qos = 1 or 2, I will save them into local database, after network reworks, I'll republish and remove them from database manually.
But now it has some problems,
One: If publish failed with qos = 1, and after network reworks, both you and I will republish them, that is wasteful.
Two: If publish failed with qos = 2, and after network reworks, both you and I will republish them, this conflict with the definition of qos = 2.
So, my question two, is there a solution to stop your republish-action? (From my point, by removing from linked-list rather than still leaving them in linked-list when publish failed will solve this problem, and at the same time, this will be more friendly for developers.)
The text was updated successfully, but these errors were encountered: