diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTAdapterListener.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTAdapterListener.java index 305367141..2562a00ef 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTAdapterListener.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTAdapterListener.java @@ -263,11 +263,11 @@ public class MQTTAdapterListener implements MqttCallback, Runnable { @Override public void run() { + int connectionDuration = MQTTEventAdapterConstants.initialReconnectDuration; while (!connectionSucceeded) { try { - MQTTEventAdapterConstants.initialReconnectDuration = MQTTEventAdapterConstants.initialReconnectDuration - * MQTTEventAdapterConstants.reconnectionProgressionFactor; - Thread.sleep(MQTTEventAdapterConstants.initialReconnectDuration); + connectionDuration = connectionDuration * MQTTEventAdapterConstants.reconnectionProgressionFactor; + Thread.sleep(connectionDuration); startListener(); connectionSucceeded = true; log.info("MQTT Connection successful"); diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTEventAdapterConstants.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTEventAdapterConstants.java index 4625c433a..88ac43171 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTEventAdapterConstants.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTEventAdapterConstants.java @@ -48,7 +48,7 @@ public class MQTTEventAdapterConstants { public static final int ADAPTER_CONF_DEFAULT_KEEP_ALIVE = 60000; public static int initialReconnectDuration = 2000; - public static final int reconnectionProgressionFactor = 4; + public static final int reconnectionProgressionFactor = 2; public static final String EMPTY_STRING = ""; public static final String GRANT_TYPE = "urn:ietf:params:oauth:grant-type:jwt-bearer refresh_token"; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/util/XMPPAdapterListener.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/util/XMPPAdapterListener.java index bf5c6fde8..b31ac945c 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/util/XMPPAdapterListener.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/util/XMPPAdapterListener.java @@ -203,10 +203,10 @@ public class XMPPAdapterListener implements Runnable { @Override public void run() { while (!connectionSucceeded) { + int connectionDuration = XMPPEventAdapterConstants.initialReconnectDuration; try { - XMPPEventAdapterConstants.initialReconnectDuration = XMPPEventAdapterConstants.initialReconnectDuration - * XMPPEventAdapterConstants.reconnectionProgressionFactor; - Thread.sleep(XMPPEventAdapterConstants.initialReconnectDuration); + connectionDuration = connectionDuration * XMPPEventAdapterConstants.reconnectionProgressionFactor; + Thread.sleep(connectionDuration); startListener(); connectionSucceeded = true; log.info("XMPP Connection successful"); diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/util/XMPPEventAdapterConstants.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/util/XMPPEventAdapterConstants.java index 304f4578a..d62f78ab2 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/util/XMPPEventAdapterConstants.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/util/XMPPEventAdapterConstants.java @@ -50,7 +50,7 @@ public class XMPPEventAdapterConstants { public static final int DEFAULT_TIMEOUT_INTERVAL = 5000; public static int initialReconnectDuration = 2000; - public static final int reconnectionProgressionFactor = 4; + public static final int reconnectionProgressionFactor = 2; public static final String DEFAULT = "default";