100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
MQTT client disconnect reporting improvements
Rich Turner7c9145495bf8
diff --git a/agent/src/main/java/org/openremote/agent/protocol/mqtt/AbstractMQTT_IOClient.java b/agent/src/main/java/org/openremote/agent/protocol/mqtt/AbstractMQTT_IOClient.javaindex 1f039cb52..64d4e522a 100644--- a/agent/src/main/java/org/openremote/agent/protocol/mqtt/AbstractMQTT_IOClient.java+++ b/agent/src/main/java/org/openremote/agent/protocol/mqtt/AbstractMQTT_IOClient.java@@ -404,12 +404,13 @@ public abstract class AbstractMQTT_IOClient<S> implements IOClient<MQTTMessage<S}LOG.finest("Disconnecting IO client: " + getClientUri());- onConnectionStatusChanged(ConnectionStatus.DISCONNECTED);+ onConnectionStatusChanged(ConnectionStatus.DISCONNECTING);}this.disconnected = true;client.disconnect().whenComplete((unused, throwable) -> {+ onConnectionStatusChanged(ConnectionStatus.DISCONNECTED);if (this.cleanSession) {removeAllMessageConsumers();}diff --git a/test/src/test/groovy/org/openremote/test/provisioning/UserAndAssetProvisioningTest.groovy b/test/src/test/groovy/org/openremote/test/provisioning/UserAndAssetProvisioningTest.groovyindex a51bac46e..a2f903417 100644--- a/test/src/test/groovy/org/openremote/test/provisioning/UserAndAssetProvisioningTest.groovy+++ b/test/src/test/groovy/org/openremote/test/provisioning/UserAndAssetProvisioningTest.groovy@@ -296,10 +296,11 @@ class UserAndAssetProvisioningTest extends Specification implements ManagerContawhen: "the client disconnects"device1Client.disconnect()- then: "all subscriptions should be removed"+ then: "all subscriptions should be removed and the client should be disconnected"conditions.eventually {assert mqttBrokerService.clientIdConnectionMap.get(mqttDevice1ClientId) == nullassert !clientEventService.eventSubscriptions.sessionSubscriptionIdMap.containsKey(mqttDevice1ClientId)+ assert device1Client.getConnectionStatus() == ConnectionStatus.DISCONNECTED}when: "the client reconnects"@@ -412,6 +413,7 @@ class UserAndAssetProvisioningTest extends Specification implements ManagerContathen: "the connection should be removed from the broker"conditions.eventually {assert mqttBrokerService.clientIdConnectionMap.get(mqttDeviceNClientId) == null+ assert deviceNClient.getConnectionStatus() == ConnectionStatus.DISCONNECTED}when: "another device connects"@@ -458,6 +460,7 @@ class UserAndAssetProvisioningTest extends Specification implements ManagerContathen: "the connection should be removed from the broker"conditions.eventually {assert mqttBrokerService.clientIdConnectionMap.get(mqttDeviceNClientId) == null+ assert deviceNClient.getConnectionStatus() == ConnectionStatus.DISCONNECTED}when: "another device connects"@@ -508,6 +511,7 @@ class UserAndAssetProvisioningTest extends Specification implements ManagerContathen: "the connection should be removed from the broker"conditions.eventually {assert mqttBrokerService.clientIdConnectionMap.get(mqttDeviceNClientId) == null+ assert deviceNClient.getConnectionStatus() == ConnectionStatus.DISCONNECTED}when: "the provisioning config is updated to disabled"@@ -583,6 +587,7 @@ class UserAndAssetProvisioningTest extends Specification implements ManagerContathen: "the connection should be removed from the broker"conditions.eventually {assert mqttBrokerService.clientIdConnectionMap.get(mqttDeviceNClientId) == null+ assert deviceNClient.getConnectionStatus() == ConnectionStatus.DISCONNECTED}when: "the provisioning config is updated to enabled"