Atos-Research-and-Innovation / IoTagent-LoRaWAN

FIWARE IoT Agent for LoRaWAN protocol (with CayenneLpp and CBOR data models)
https://fiware-lorawan.readthedocs.io/en/latest/
Other
34 stars 40 forks source link

Fix MQTT reconnection bug #173

Open RosLD opened 1 year ago

RosLD commented 1 year ago

Problems found

The first problem I found is that if the iotagent is provisioned with a group, and thus, subscribed to a topic if the broker disconnects in my case does not resubscribe to those topics, hence all the reports made from the devices will be ignored.

The second problem is about a bug in the code. As I could understand, in case of a disconnection it is supposed to wait a larger time every time it tries to reconnect and fail, it will try 5 times, but there is a problem with the function sleep, because it is not executed asynchronously and thus the reconnection times are not incremental, there will be 1 second between each trial because it is the default time in the mqtt library. I could not fix the async problem either, I think it is related to the mqtt library and how its event handler works.

Proposed changes

Types of changes

What types of changes does your code introduce to the project: Put an x in the boxes that apply

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

github-actions[bot] commented 1 year ago

CLA Assistant Lite bot:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


Daniel seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheckcla in this Pull Request

RosLD commented 1 year ago

I have read the CLA Document and I hereby sign the CLA