-
Notifications
You must be signed in to change notification settings - Fork 160
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
connect() blocks forever if reconnect configured and broker cannot be reached #302
Comments
This was actually intended. Mqtt5Client.builder()
...
.automaticReconnectWithDefaultConfig()
.addDisconnectedListener(context -> {
if (context.getClientConfig().getState() == MqttClientState.CONNECTING) {
context.getReconnector().reconnect(false);
}
})
... |
Thanks for the workaround! There are three options on top of my mind:
Which option fits best depends on the use-case. Make the behavior configurable? |
Hello i just want to poke this, cause it tooks me 2 days to understand why "exceptionally" is not working This definitely needs to be highlighted somewhere |
I think I might have encountered this problem. @dowhiletrue I think throwing an exception should be the default behavior as it informs the developers if their connection configuration is incorrect; I think jdbc connection pools also have such default behavior. @SgtSilvio can you please explain what happens if I use your workaround? does it attempt to reconnect automatically initially or otherwise or does it abandon reconnection and throw an exception? |
@SgtSilvio Is it not possible to have automaticReconnectWithDefaultConfig() and that
throws error? |
Expected behavior
Connecting a client with reconnect configured should throw if it can't connect initially.
Actual behavior
It blocks infinitely
To Reproduce
Reproducer code
Mqtt5Client.builder().serverHost("hostWithoutRunningBroker").automaticReconnectWithDefaultConfig().toBlocking().connect(...)
Details
The text was updated successfully, but these errors were encountered: