ubidots / ubidots-mqtt-esp

MIT License
40 stars 23 forks source link

subscription not reliable #3

Closed universam1 closed 7 years ago

universam1 commented 7 years ago

I have the issue that following code will not return a broken subscription:

if (!client.connected()) { client.reconnect(); subscribe(); }

After some hours the subscription is not present anymore although client.connected() returns true! The publishing though keeps on working.

This may be related to wifi based ip address changes happening.

Is there a better way to test subscription than the above from the examples?

jotathebest commented 7 years ago

Greetings,

Our library is based on PubSubclient library for making the MQTT connection, actually that library only has the method connected() in order to know if the MQTT connection is up, because of this we implemented a new subscription query if this method returns false.

At the docs of the library you can check all the methods available, maybe the state() method can give you a better debug but it is not different of connected() because it would return a -1 if the connection was lost.

You can make a debug with the subscribe() itself method too, it returns false if the subscribe query failed, so you would make a loop for trying to subscribe if you get a false from this method instead of connected() method.

As this library is made from Ubidots and release 'As Is', as soon as the maker of PubSubclient creates a best debug for subscription we will add it here or you may ask him for your certain problem.

Another important thing is to know that Ubidots had a window maintenance this week, so in some geographical locations the MQTT connection was down.

Regards

universam1 commented 7 years ago

Thanks for the info! That means there is no API call from Ubidots available to verify the active subscription.

jotathebest commented 7 years ago

The active subscription is not on the API client side, it's on the client side, that's why I suggest you to use the subscribe() method answer for getting the subscription status.

Regards