-
Notifications
You must be signed in to change notification settings - Fork 179
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
mqtt sets reconnection timeout to expire #521
Comments
Sorry I'm not understanding you, are you saying you want the client to stop trying to connect after 5 seconds if it doesn't succeed in connecting? I don't know what this means 'He keeps showing a connection, but the MQTT server is available, but has not been successfully reconnected, and is still connecting' |
What I mean is that when the server is restarted, the client will try to reconnect, but it will always show the connection, and when the server MQTT is restarted successfully, it will still show the connection and will not reconnect successfully |
More than half an hour later, it still shows a connection, no connection timeout, connection error, connection success |
I'll need a client log to see what's going on here, if you have disconnected which I assume you have as you have called on disconnected you have to call connect again to reconnect. |
|
|
So far the log has been indicating /// Set the correct MQTT protocol for testing against mosquito, and I have no callback to handle manually disconnecting @shamblett |
I set up a timeout connection for 5S, and after 5S, there are no exceptions or event callbacks to let me know that the timeout has occurred |
The logs seem incomplete I cant see the sending of a connect message nor receipt of a connect ack. Could you supply a complete client log of the initial connection and what happens when your MQTT broker disconnects. |
This is my entire log, and it says' NOT sending ping - not connected 'every 5s What I am wondering now is, I set the timeout connection for 5s, why there is no exception after 5s |
@shamblett Looking forward to your help |
There is a gap in your logs of 5 seconds from here -
to here
It looks as though you are not connected but I don't know why, it should show the sending of your connect message as in the example below -
Looking at your code above you have this -
This should be set to true, also you do seem to have an onDisconnected callback -
The calling of this should also be logged, please supply a complete client log. |
This is already the complete log, MQTT is not connected, the connection time has expired and there are no exceptions or callbacks |
onDisconnected is not called, MQTT is always connected, with no timeout or exception |
This is not a complete log from the MQTT client, please look through the issues for examples of complete logs also you say 'onDisconnected is not called, MQTT is always connected, with no timeout or exception' but your log above is showing its not connected -
|
This is indeed all the logs, perhaps because the server is not starting service, but now I can't trigger any callbacks, and after 5S, there are no timeout exceptions |
ShareX_bXRbJ49Cpv.mp4 |
Sorry uouve lost me completely now, Ive never seen the client skip log entries also This is indeed all the logs, what does this mean 'perhaps because the server is not starting service, but now I can't trigger any callbacks, and after 5S, there are no timeout exceptions' What server? What service? |
ShareX_AZu05upVZc.mp4This is all the logs in one minute, and I'll briefly describe the problem I encountered
Looking forward to your help |
|
I can't see anywhere above where you set a timer for 5 seconds, however what I think you need to do is - You have mqttClient?.connectTimeoutPeriod = 3000;, set this to 1000 You have maxConnectionAttempts 1, set this to 5 This will give you 5 connection attempts each 1 second apart, if the client is not connected after this period it will stop trying, giving you your 5 seconds, after that you can do your manual disconnect etc. You wont get an onDisconnected callback. |
My understanding is that I set connectTimeoutPeriod = 3000. After more than 3S, mqtt_clicnt will help me disconnect and throw a timeout exception. Do I now need to customize a timer to manually close the connection? |
Does the API documents say the client throws an exception after any kind of timeout? I don't think it does. Your understanding is wrong, please read the API docs. You can start as many timers as you wish and do with them what you wish, anything that happens outside the client is not really of concern to this package. Please identify any bugs you find or feature you want on added on the client, this is not a general purpose forum for how to handle MQTT clients. |
If you want to add a callback or function when the connection times out, mqtt_client can throw a timeout exception. |
OK, so are you asking for a callback to be added in between connection attempts, i.e. if maxConnectionAttempts is 5 then you will trigger the callback on each failed connection attempt. If that's the case raise an issue for this documenting exactly what you want and which use case this will help with and I'll mark it as a feature request. |
@shamblett #523 added a new request, describing the functionality and usage, looking forward to adding it, very urgent, thank you for the great work |
OK, closing this moving the work to #523 |
mqtt sets reconnection timeout to expire ,mqtt_client reconnection timeout did not work
As currently configured, it will always be reconnected without connection timeouts or connection failures, without any ### errors
How can I achieve an error, connection exception or connection timeout if the connection exceeds 5S and be able to catch it
He keeps showing a connection, but the MQTT server is available, but has not been successfully reconnected, and is still connecting
The text was updated successfully, but these errors were encountered: