Topic: Intermittent Network Disconnect Issue with WolfMQTT

Hello everyone,



I'm currently using the Microchip's MCU in my project, and I’ve integrated WolfMQTT to handle communication with other devices. However, I’ve been facing an issue where the network connection sometimes disconnects unexpectedly.

From my serial logging, I can see that a TIMEOUT error typically occurs just before the NETWORK error, but I’m unable to pinpoint the exact cause. The TIMEOUT error is reproducible in my local environment, but the NETWORK error happens intermittently and cannot be replicated consistently.

I’m wondering if anyone has encountered a similar issue with WolfMQTT?



- Under what circumstances does WolfMQTT trigger a NETWORK error?

- Are there any specific configurations or common pitfalls that I should look into to prevent this kind of disconnection?



Any insights or suggestions would be greatly appreciated!



Thank you in advance!

Share

Re: Intermittent Network Disconnect Issue with WolfMQTT

Hi iskim,

Welcome to the wolfSSL Forums.

The MQTT protocol uses a keep-alive message called a ping to sustain the communication channel between a client and the broker. During the client connect, the keep_alive_sec field is sent to broker, which uses that to determine if the client has lost it's connection. Some brokers use that value (in seconds) times 1.5 to finally disconnect the client. If your client is not sending the ping (or ping response) within the time frame negotiated, then the broker will disconnect the client.

> - Under what circumstances does WolfMQTT trigger a NETWORK error?

A network timeout can occur when the client attempts to read or write data to the network, but the operation takes too long. This is configurable with the timeout_ms parameter when calling MqttClient_NetConnect.

> - Are there any specific configurations or common pitfalls that I should look into to prevent this kind of disconnection?

A network error might not even be on client side. The application should handle network problems gracefully and allow reconnection attempts.


Could you tell us more about your MQTT project and your location for our support records? Feel free to email us at support@wolfssl.com for a more private conversation.

Kind regards,
Eric - wolfSSL Support

Re: Intermittent Network Disconnect Issue with WolfMQTT

I’ve sent you an email. Could you please check it out?

Share