Closed missourian55 closed 1 year ago
Hi @missourian55
If you use automaticReconnect
, then there is no reason to call if (!isConnected) { disconnect; connect; }
yourself.
Currently, the client does not support disconnecting and reconnecting yourself when it will automatically reconnect (https://github.com/hivemq/hivemq-mqtt-client/issues/302).
So, everything should work and if you remove the if (!isConnected) { disconnect; connect; }
code, then you should not get any exceptions logged.
@SgtSilvio Thank you! I added this if (!isConnected) { disconnect; connect; }
after noticing that client is not automatically reconnecting. Does MQTT server have any special support for client automaticReconnect
? In my case MQTT server is Solace
@missourian55 sorry for the delayed response. I don't know how Solace handles reconnects/client takeovers and so on. To see if the server rejects reconnect attempts, please add a ConnectedListener and DisconnectedListener which log all connect attempts and failures:
MqttClient.builder()
...
.automaticReconnectWithDefaultConfig()
.addConnectedListener(context -> log.info("connected"))
.addDisconnectedListener(context -> log.info("disconnected by {}, cause {}", context.getSource(), context.getCause()))
...
Hi @missourian55 - it's been while since this issue has been updated. I'm going to close it for now but if anything remains, feel free to re-open it again or file another issue. Thanks for using the HiveMQ client!
I am trying to simulate un-graceful disconnect and client takeover (in this case, the broker doesn't support it). Like to know how to re-establish the connection? I am not sure if this is a bug with HiveMQ client, but would like to disclose what I am testing and appreciate any recommendations.
To Reproduce
Steps
Reproducer code
Details