shamblett / mqtt_client

A server and browser based MQTT client for dart
Other
548 stars 176 forks source link

MqttConnectOptions setting serverURIs is invalid #175

Closed wkdwjddns22 closed 2 months ago

wkdwjddns22 commented 4 years ago

I want to try the MqttConnect option to set the server URI to connect to multiple mosquito servers. There seems to be no setting

shamblett commented 4 years ago

The client only connects to one broker at a time, what use case do you have where you would need to do this?

wkdwjddns22 commented 4 years ago

I need a function during migration from existing java to flutter

paho java api doc : setServerURIs public void setServerURIs(java.lang.String[] array) Set a list of one or more serverURIs the client may connect to. 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:

tcp://localhost:1883 ssl://localhost:8883 If the port is not specified, it will default to 1883 for tcp://" URIs, and 8883 for ssl:// URIs. 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:

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.

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

Parameters: array - of serverURIs

shamblett commented 4 years ago

Ok, I see what you mean, this has been asked for before by a user, I'll have a look at this. For now you could use separate clients and manage this in your code but this is not optimal.

shamblett commented 2 months ago

There is no plans to incorporate HA into the client, it is better if the user controls this manually going forward.