andriyadi / AzureIoTHubMQTTClient

Azure IoT Hub client for ESP8266 using MQTT
31 stars 17 forks source link

Disconnects after *not* sending? #6

Open onionhammer opened 6 years ago

onionhammer commented 6 years ago

I have a very simple device that if there is no temperature sensor is connected it just sends an event saying "no temperature sensor available", and then sits there connected to the IoT hub.

For some reason after an indeterminate amount of time, however, the device appears as 'disconnected' from the IoT hub, but doesnt log anything over serial debugging and doesn't reboot. It's just disconnected with no clues as to why.

Right now I'm really just looking for guidance as to how I can track this issue down. There doesn't seem to be much of a pattern to it, sometimes it takes an hour to disconnect, sometimes it takes 2 days.

andriyadi commented 6 years ago

It’s not scientific response. As you know that the underlying MQTT functionality is provided by PubSubClient library. There could be an issue in it. As soon as MQTT is not connected, you can make sure that it should try to reconnect.

onionhammer commented 6 years ago

@andriyadi okay, but currently there's no event indicating that it's disconnected. Do you know if PubSubClient exposes this event and AzureIoTHubMQTTClient just isn't relaying it through its event mechanism?

onionhammer commented 6 years ago

@andriyadi It looks like connected() is returning false from PubSub, but AzureIoTHubMQTTClient::run() (which calls loop()) is not re-connecting, and is swalling the output from PubSub's loop() which returns false if not connected. I set up some debug statements and basically it went:

Connected
Connected
Connected
Connected
Connected
Disconnected
Disconnected
Disconnected

Eventually it transitioned to disconnected without any other logging or events