Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added sender with reconnect example #15

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

valerionew
Copy link

The poll() call is moved inside the non-blocking delay cycle, this fixes #14

Also, a reconnecting example is added


// call poll() regularly to allow the library to send MQTT keep alives which
// avoids being disconnected by the broker
mqttClient.poll();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain why this needs to be moved? What issue's where you seeing?

The idea is .poll() should be called very frequently and sending should happen on the interval

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #14
Probably calling poll so frequently somehow gets my client disconnected after 2-3h. I didn't dig deeper, as moving the poll seemd to have fixed the issue, or at least reduce drastically the number of disconnections

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@5N44P thanks for the reply. At this time, I'm not keen to move forward merging this change until we further understand exactly why it fixes things.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any suggestions on how or what to test?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to uncomment this line to start and enable debugging of the library: https://github.com/arduino-libraries/ArduinoMqttClient/blob/master/src/MqttClient.cpp#L22

We need to track down if there is something wrong at the WiFi or MQTT level.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just merge this PR? It already contains the reconnect example

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @5N44P 👋 Unfortunately not really ... even in your example code only you've moved the poll inside the timed function. As long as we don't understand from where exactly the problem originates hiding it is not a solution.

Copy link
Author

@valerionew valerionew Apr 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aentinger how can we debug this?
I'm aware that reconnecting doesn't fix the problem, but if it makes the library usable for everyone it should be at least proposed as an example.
What I'm thinking, by the way, is that random and erratic disconnections can be expected, and if handled with a reconnection are not an issue. The polling without delay just gives an higher number of disconnections per unit of time, keeping the frequency per request unaltered.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I would be doing is this: Solder a SWD connector to the bottom of your MKR board and connect your favourite debugger + graphical debugging front-end. Trying to get to the bottom of this issue via Serial.print(...)-debugging is probably going to be quite hard.

I'd do it myself but unfortunately there are a lot of high priority items on my list which is why I won't get to it anytime soon 😞 If you could help out here it would be greatly appreciated. Talking about debugging, the Arduino Pro IDE comes with experimental debugging support.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or of course uncomment the line suggested in #15 (comment) .

@CLAassistant
Copy link

CLA assistant check
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 have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Client stops sending mqtt data after some hours
4 participants