-
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
Need shorter timeout when connection can't be established #522
Comments
The connection timeout period from the API -
its the period between successive connection attempts(to allow backoff if needed) not the period the connection must complete in. There is no client setting for this. In your case the network layer seems to be holding the socket for 1min 15 seconds then erroring. Do you ever successfully connect or does it do this every time? If its every time I'd look at your network layer. |
Ok. Sorry for misunderstanding the parameter and thanks for pointing out the docu. Maybe I explain my use case: Therefore, I try to connect via mqtt. When the device is working, everything is fine and the connection is established quite fast. When the device is not switched on, the time until I get an exception is just too long for my use case. Any idea how I could solve this? |
Yes, the problem I encountered should be the same as yours. If the mqtt server is not opened, it takes too long for me to receive the exception. Sometimes it takes a few minutes and sometimes it takes longer. Sometimes I don’t even receive the exception reminder. This way I have no way of knowing my current connection status and no way of manually disconnecting and reconnecting |
Have you tried not connecting the client to a device you seem to know is not switched on? This relatively pointless as it will never work. You can use many other methods(ping etc.) to determine if your device is switched on before trying to connect. |
I have an app which will control the external device. I don't know if the user has turned on this device or not. |
Are you saying the same thing about this need? |
@laterdayi Its hard to tell, do you know if your device is on or not before you try to connect? @Vera-Spoettl The MQTT protocol is not useful for detecting whether devices have been switched on or not, your using the wrong tool especially in the context of Dart/flutter, see below. The client sits atop the Dart/flutter runtime and reacts to events produced by the runtime, if the runtime produces no events or takes minutes to do this there is nothing the client can do. If you want an explanation as to why the runtime can take over a minute to detect an error in the network stack before it communicates this to the client then please ask the google Dart/flutter guys not me. Why can't you just ping the device? This will at least tell you the device is alive, note it doesn't matter if the MQTT broker is running or not, the client can handle this on connection. |
We have to refactor the handling of the external devices. Up to now, we have no "check-in" of devices when they are switched on. However this will be implemented in one of the next releases. Otherwise this solution won't be scalable. |
Expect to solve first #523, to solve the current problems, thank you |
I'm setting the connection timeout period to 1000 milliseconds. However the connect attempt takes more than a minute until it returns with an error.
Is there a possibility to shorten this? In my case something like 10 seconds would be more appropriate.
Thanks for your help!
The text was updated successfully, but these errors were encountered: