hivemq-mqtt-client
hivemq-mqtt-client copied to clipboard
Support URIs to connect to a cluster (multiple server)
Problem or use case
Some MQTT server - like HiveMQ - support clustering. In a failure szenario a client can connect to one of the still available server instances. It would be great if the (auto re)connect feature of the hivemq-mqtt-client would support this.
The Paho MQTT Client supports this by setting a list of ServerUris. During a (re)connect attempt the library then checks for an availble server of the list and connects.
Preferred solution or suggestions
It would be great if also the MQTT Driver would support this kind of Server/Cluster configuration similar to the Paho MQTT client. There would be no need for a load balancer or somethind else in this case.
Also see: Paho MqttConnectOptions#setServerURIs
Hi @FrVaBe This is definitely a feature that we want to integrate in the automatic reconnect feature. In the meantime you can already implement (re)connecting to different broker addresses on your own. The following is just a hint, not a full implementation:
final Mqtt5BlockingClient client = Mqtt5Client.builder()
.serverHost("broker.hivemq.com")
.automaticReconnectWithDefaultConfig()
.addDisconnectedListener(context -> {
...
context.getReconnector()
.transportConfig().serverHost("broker2.hivemq.com").applyTransportConfig();
...
})
.buildBlocking();
Hey! Is there any update on this feature? Is it still on the roadmap?