Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After reconnect, Mosquitto exceeds receive maximum setting sent by broker #1822

Closed
Sarek opened this issue Sep 11, 2020 · 4 comments
Closed

Comments

@Sarek
Copy link

Sarek commented Sep 11, 2020

We discovered that when used in an MQTT 5 scenario the mosquitto client library exceeds the receive maximum setting sent by the broker in the CONNACK packet. By default, HiveMQ sends a receive maximum setting of 10 in its answer

Here is some information on how to reproduce with HiveMQ as the broker and using mosquitto_pub to send messages:

  1. Create a testfile with 1000 lines
for i in {1..1000}; do echo "line$i" >> /tmp/testfile; done
  1. Download and start HiveMQ. Java runtime needs to be at least version 11.
wget https://github.com/hivemq/hivemq-community-edition/releases/download/2020.4/hivemq-ce-2020.4.zip
unzip hivemq-ce-2020.4.zip
cd hivemq-ce-2020.4/bin
./diagnostics.sh
  1. In another window, patch and compile mosquitto. The reproduction.patch.txt is just necessary to make mosquitto_pub sleep for 10 seconds, so we have time to stop HiveMQ and force a reconnect.
git clone https://github.com/eclipse/mosquitto
cd mosquitto
git checkout v1.6.12
git am -k ../reconnect.patch.txt
make WITH_WEBSOCKETS=yes DOCDIRS= -j4
  1. Start mosquitto_pub and wait for the message Freeze HiveMQ broker within next 10 secs
./client/mosquitto_pub -t mytopic -t clientId1 -q 1 -d -l -D Connect session-expiry-interval 1000000 -V 5 --repeat 10 < /tmp/testfile
  1. After the message is displayed, stop the HiveMQ broker
kill -STOP $(pgrep -f hivemq.jar)
  1. After the 10 seconds have expired, you should see 10 messages being published. Now kill the HiveMQ broker and start it again:
kill -9 $(pgrep -f hivemq.jar)
./diagnostics.sh
  1. mosquitto_pub will now retransmit the original 10 messages, but also continue publishing, until it receives a DISCONNECT packet with reason code 147 ("Receive maximum exceeded").
ralight added a commit that referenced this issue Sep 11, 2020
@ralight
Copy link
Contributor

ralight commented Sep 11, 2020

Thank you for the detailed description and patch, that made it very straightforward. Could you please try the fixes branch, I believe this is now fixed.

@Sarek
Copy link
Author

Sarek commented Sep 14, 2020

I tested with the fixes branch on a53712a, but I still see the same behaviour that a DISCONNECT with reason code 147 is received.

@Sarek
Copy link
Author

Sarek commented Sep 14, 2020

Okay, I have to correct this. I mistested and used my system's mosquitto library instead of the newly compiled one. When actually using the new one, it works. Thanks a lot @ralight!

@ralight
Copy link
Contributor

ralight commented Sep 14, 2020

Excellent, thanks for reporting back. I've made that same mistake numerous times.

@ralight ralight closed this as completed Nov 2, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants