|[paho-dev] Java Client now handles a list of MQTT servers.|
Each serverURI specifies the address of a server that the client may connect to. Two types of connection are supported tcp:// for a TCP connection and ssl:// for a TCP connection secured by SSL/TLS. For example:
If serverURIs is set then it overrides the serverURI parameter passed in on the constructor of the MQTT client.
When an attempt to connect is initiated the client will start with the first serverURI in the list and work through the list until a connection is established with a server. If a connection cannot be made to any of the servers then the connect attempt fails.
Specifying a list of servers that a client may connect
to has several uses:
1. High Availability and reliable message delivery
Some MQTT servers support a high availability feature where two or more "equal" MQTT servers share state. An MQTT client can connect to any of the "equal" servers and be assured that messages are reliably delivered and durable subscriptions are maintained no matter which server the client connects to.
The cleansession flag must be set to false if durable subscriptions
and/or reliable message delivery is required.
2. Hunt List
A set of servers may be specified that are not "equal"
(as in the high availability option). As no state is shared across the
servers reliable message delivery and durable subscriptions are not valid.
The cleansession flag must be set to true if the hunt list mode is used
array - of serverURIs
Back to the top