Closed u93 closed 1 year ago
Hello u93,
For unstable connections, the most relevant timeouts will be the values passed to Openssl_Connect()
for sendTimeoutMs
and recvTimeoutMs
. Increasing the value on these timeouts may reduce the occurrence of MQTTRecvFailed
errors by giving more time for a packet to arrive before it is considered lost. However, if you are experiencing packet loss, modifying timeouts may not improve your situation significantly. You may be able to recover from the MQTT_ProcessLoop()
errors you specified by setting up a retry/reconnect mechanism, but the data loss would still occur.
The timeoutMs
for MQTT_ProcessLoop
is an implementation detail specifying how long the calling process should repeatedly check for incoming packets/handle KeepAlive/send packets. An application can use a timeoutMs
of 0 to do a single iteration and return immediately. Modifying this value shouldn't affect the reliability of your connection.
The timeoutMs
in MQTT_Connect()
determines how long to wait for the initial CONNACK
packet. Modifying this value will only affect the initial connection process, and otherwise should not impact your connection reliability.
I hope this helps - feel free to respond with any additional questions.
Feel free to reopen this issue if you have any further questions.
Hi,
We are looking to use the SDK in places where the network connectivity is unstable, and we are looking to know the best possible parameters for a reliable connection.
We based our application out of the shadow demo application
Specifically looking for proper timeout values for:
Mqtt_ProcessLoop()
timeouttimeoutMs
Openssl_Connect()
timeoutssendTimeoutMs
andrecvTimeoutMs
MQTT_Connect()
timeouttimeoutMs
Also, what are the proper ways to recover the application using the SDK after receiving the following status from
Mqtt_ProcessLoop()
:MQTTRecvFailed
MQTTKeepAliveTimeout
MQTTIllegalState
One of the reasons I ask this is because I get these sometimes, and I'm not sure what can be causing it... maybe my application is doing something that is blocking the reception of a package, although I doubt it, but it would be good to know if the timeouts setups can help to improve in that regard.
Thanks in advanced!