-
Notifications
You must be signed in to change notification settings - Fork 13
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
Correct use of mqtt->yield #13
Comments
Hi @gjt211 You can specify any value you like. The value in milliseconds. The default value is You must call the function regularly or when you are expecting the new incoming message and/or You can't send Answers:
I am working on the improvement of the Plese, give me more info about your application |
@gjt211 |
Hi @monstrenyatko I noticed the default value of 1000mS in the yield() call inside your library later after I posted my original question. I was aware the 30000 value was just an example and I used it here in my question as such. I initially ran the demo code modified with a publish to my broker with yield(30000L) for 24 hours to see if I would get any reconnects which I did not. My code does many things in the background also. Here is a list.
I actually want the debug output right now so I can monitor what is going on when the reconnect occurs. I commented out the Yield debug output as it was filling up my log with info I don't really need. I have implemented a timer that checks if 150 milliseconds have passed and yields for 50mS each time it happens. (In the last 12 hours I had reconnects between 1 and 20 from various units). My main loop currently is this;
My Question, when a publish is sent, does the keep alive timeout get reset? Here is a paste from the debug output of my code where a reconnect occurred. Note that my keep alive is 45 seconds and I reduced the 0.8 keep alive to 0.7 in your library to see if that would help with my reconnects.
The FWVER publish is used by my server for two things. It is only sent (published) when the device connects to the broker. One is so I know what version of firmware is running in each device, and secondly each time the server receives the firmware version it knows the device has reconnected and increments a counter so I can see how frequently there are reconnects. FYI: I am not sure if being able to send the With point 2 from my original post, I now understand that if I don't pass it a value it will default to 1000mS. I really meant to ask what is the minimum time I could Sorry for the long post and appreciate your help and guidance. |
Hi again @monstrenyatko Maybe a simpler way to say what I would like with regard to I would like to use Having a blocking delay while it's only waiting to see if something is coming in doesn't seem the best way to do things, unless I misunderstand how it's working (which is most likely!). Further investigations after adding and using Hopefully you can understand what I am trying to say. |
@gjt211 With the current implementation, the If the client is connected the |
I have been testing this library for a few days (was using PubSubClient) and so far I really like it but don't understand the correct usage of
mqtt->yield(30000L)
My problem is it introduces an unacceptable delay in my main loop.
Questions
mqtt->yield();
and it will automatically yield for the required time?Sorry for the many questions, I am trying to understand how it works so I can best write my code to accommodate the library.
Is there a way to manually send the keep alive ping?
FYI: I have temporarily commented out the debug output for the
mqtt->yield()
function in 'MqttClient.h' as I am logging my serial output trying to find rare & random reconnects that have been causing me headaches.Thank you in advance.
The text was updated successfully, but these errors were encountered: