Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] paho.mqtt.embedded-c, sometimes timeout in cycle() when calling sendPacket()

Hi all,

Regarding:
MQTTClient/src/MQTTClient.h:
template<class Network, class Timer, int MAX_MQTT_PACKET_SIZE, int b>
int MQTT::Client<Network, Timer, MAX_MQTT_PACKET_SIZE, b>::cycle(Timer& timer)

I'm suspecting that there is timeout hitting too easily, repro steps: 
  1. You are waiting in yield() > cycle() > readPacket() to message arrive
  2. Timeout is almost elapsed when message received, e.g. PUBLISH, for sure sometimes this happens
  3. Your ipstack library might be slowish e.g. when accessing wifi over UART
  4. Same remaining timeout value is used in sendPacket(), the remaining timeout can be very small when sending PUBACK.
  5. You hit timeout in your implementation of ipstack.write()
It helps if reseting the timer before sendPacket(), like this, needed in two places in cycle():

timer.reset();
rc = sendPacket(len, timer);

For timer.reset() there needs to be respective implementation in Countdown(), something like this:

void reset() { countdown_ms(default_ms); }
...
private:
uint32_t default_ms; // Need to be set when timer is initiated

Hopefully you can see my point.

Do you think this is real problem (and would fix be ok) or am I missing something in my ipstack implementation? 

BR, Petri


Back to the top