wolfSSL / wolfMQTT

wolfMQTT is a small, fast, portable MQTT client implementation, including support for TLS 1.3.
https://www.wolfssl.com
GNU General Public License v2.0
521 stars 155 forks source link

MHC3 PIC32MZ - Client stops handling incoming messages if it stops publishing #290

Closed manolisss closed 2 years ago

manolisss commented 2 years ago

Hello,

We have a project that is based on the MHC3 wolfMQTT template which we have adapted to our project's specific needs.

Upon startup, the MCU subscribes to topics and then publishes a status message. We noticed that if we only publish once and then stop, the message handler for the incoming messages from our subscriptions seems to stop working. In this case, we see in Wireshark that an MQTT Publish Message arrives from the broker, the MCU responds with a TCP ACK but there is no MQTT PUB ACK and the MCU doesn't seem to understand that a message has arrived. The actions that occur upon receiving an incoming message are not triggered.

If, on the other hand, we sustain the publishing of messages periodically, then everything works normally and we receive the messages from our subscriptions normally.

Any idea what could be going wrong here?

dgarske commented 2 years ago

Hi @manolisss ,

Thank you for your question regarding use of wolfMQTT with Microchip Harmony. All of the Harmony examples use wolfMQTT with non-blocking mode enabled. I suspect the publish structure is not being cleared (memset to 0). Are you able to share an example of the code being used?

Also we recently merged in several non-blocking fixes in this PR: https://github.com/wolfSSL/wolfMQTT/pull/288. If possible can you try integrating these changes and testing? We improved the code to handling ensuring the packet objects are reset prior to use.

Thanks, David Garske, wolfSSL

manolisss commented 2 years ago

Hello @dgarske,

Thank you for taking the time to respond so fast, we will integrate the changes from the source files and get back to you with feedback.

Best regards, Manolis

manolisss commented 2 years ago

Hello @dgarske,

The problem was that the state machine did not return to the MSG_WAIT state, we improved and it works fine now. We also used the latest committed source files and everything seems to work fine.

Thanks again for taking the time to respond!

Best regards, Manolis