Assign a list of Brokers that the Client will attempt to connect to.
mqtt_client & brokers( std::string hosts, uint16_t default_port = 1883 ) = default;
The Client will cycle through the list of hosts, attempting to establish a connection with each until it successfully establishes a connection.
Name |
Description |
---|---|
hosts |
List of Broker addresses and ports. Address and ports are separated
with a colon |
default_port |
The default port to connect to in case the port is not explicitly
specified in the |
![]() |
Important |
---|---|
This function takes action when the client is in a non-operational state,
meaning the |
Some valid hosts
string:
std::string valid_hosts_1 = "broker1:1883, broker2, broker3:1883"; std::string valid_hosts_2 = "broker1";