BW16 - MQTT publish blocking at random intervals

After closed the disconnect issue, I discovered that it would blocking 3-5s when publish.
I guess the disconnect issue was to prevent mqtt disconnection caused by blocking, but the blocking problem has not been solved.
Maybe somewhere still need to be sloved.

When I set the publish freq. to 1 Hz, you can see the publish would blocking 3s sometimes.

Hi @AlanWL,

After testing, i have this issue too. I may have found the solution. The delay is affected by the recvTimeout. I didn’t notice any delay when I set it to 1000.
image

But please allow me some time to verify whether this is really the cause of the delay, and I will get back to you as soon as possible.

Thank you.

Hi @daphwl ,
Looking forward to the results of your follow-up tests.
Thank you very much for your reply!

Hi @AlanWL,

The delay is caused by recvTimeout, and the code is working as intended. When not publishing, the MQTT client main loop is continuously polling for new received data, each time this happens, it may take up to 3 seconds, thus leading to the ~3 second between messages. So to solve the delay issue, you should change the recvTimeout to a time duration shorter than your intended publish frequency.

hi @daphwl ,
When I set recvTimeout to 5 and change the publish frequency to 10Hz, it would still happend the data lost.
I’m not sure where the problem might be.
The problem jsut like the picture shown.

After testing, this problem only happened at 10Hz publish freqency.
When I set 5Hz and 1Hz, it can work as intended.
But I still want to work fine at 10Hz.

Hi @AlanWL,

I have tested at 10Hz publish frequency for the whole night, but i can’t reproduce the issue.
Maybe it is due to network congestion?
How frequent does this occur?

Hi @daphwl,
I’m not sure it is due to network congestion.
I publish data to public hivemq broker, and It occurs once in a few minutes.
How package size you publish ?
My package size is 700-800 bytes.
In the past, I sent to the local SIoT Broker at a frequency of 10Hz and this problem did not occur, so this issue caused by data processing can be ruled out.

After testing on my side, i didn’t see any issue. I tested it with public hivemq broker and my package size is 744 bytes. You should try to set up a mqtt broker on your computer in your own network, and see if the issue still exists.

Hi @daphwl ,
When I try the local broker, it still happen the blocking issue.
In my project, I use lot of function such as ntp, rtc,uart,watchdog…etc.
So I dont know how to let you reproduce the issue…
I will keep testing to find the problem.


image

1 Like