[mqtt] connectionStateChanged(CONNECTED) called twice (#12200)
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>pull/12207/head
parent
97db73938d
commit
73b805b115
|
@ -114,8 +114,6 @@ public abstract class AbstractBrokerHandler extends BaseBridgeHandler implements
|
|||
}).thenAccept(v -> {
|
||||
if (!v) {
|
||||
connectionStateChanged(MqttConnectionState.DISCONNECTED, new TimeoutException("Timeout"));
|
||||
} else {
|
||||
connectionStateChanged(MqttConnectionState.CONNECTED, null);
|
||||
}
|
||||
});
|
||||
connectionFuture.complete(connection);
|
||||
|
|
|
@ -59,19 +59,18 @@ public class BrokerHandler extends AbstractBrokerHandler implements PinnedCallba
|
|||
@Override
|
||||
public void connectionStateChanged(MqttConnectionState state, @Nullable Throwable error) {
|
||||
super.connectionStateChanged(state, error);
|
||||
// Store generated client ID if none was set by the user
|
||||
final MqttBrokerConnection connection = this.connection;
|
||||
String clientID = config.clientID;
|
||||
if (connection != null && state == MqttConnectionState.CONNECTED) {
|
||||
String clientID = config.clientID;
|
||||
if (clientID == null || clientID.isBlank()) {
|
||||
// Store generated client ID if none was set by the user
|
||||
clientID = connection.getClientId();
|
||||
config.clientID = clientID;
|
||||
Configuration editConfig = editConfiguration();
|
||||
editConfig.put("clientid", clientID);
|
||||
updateConfiguration(editConfig);
|
||||
} else {
|
||||
publish(config.birthTopic, config.birthMessage, config.birthRetain);
|
||||
}
|
||||
publish(config.birthTopic, config.birthMessage, config.birthRetain);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue