/** * Process a Connection Lost notification * * @param data */ private void connectionLostAction(Bundle data) { if (callback != null) { Exception reason = (Exception) data .getSerializable(MqttServiceConstants.CALLBACK_EXCEPTION); callback.connectionLost(reason); } }
public void mockDisconnect() { isConnected = false; mockCallback.connectionLost(new Exception("disconnect")); } }
/** * Process a notification that we have disconnected * * @param data */ private void disconnected(Bundle data) { clientHandle = null; // avoid reuse! IMqttToken token = removeMqttToken(data); if (token != null) { ((MqttTokenAndroid) token).notifyComplete(); } if (callback != null) { callback.connectionLost(null); } }
/** * This method is called when the connection to the server is lost. If there * is no cause then it was a clean disconnect. The connectionLost callback * will be invoked if registered and run on the thread that requested * shutdown e.g. receiver or sender thread. If the request was a user * initiated disconnect then the disconnect token will be notified. * * @param cause the reason behind the loss of connection. */ public void connectionLost(MqttException cause) { final String methodName = "connectionLost"; // If there was a problem and a client callback has been set inform // the connection lost listener of the problem. try { if (mqttCallback != null && cause != null) { // @TRACE 708=call connectionLost log.fine(CLASS_NAME, methodName, "708", new Object[] { cause }); mqttCallback.connectionLost(cause); } if(reconnectInternalCallback != null && cause != null){ reconnectInternalCallback.connectionLost(cause); } } catch (java.lang.Throwable t) { // Just log the fact that a throwable has caught connection lost // is called during shutdown processing so no need to do anything else // @TRACE 720=exception from connectionLost {0} log.fine(CLASS_NAME, methodName, "720", new Object[] { t }); } }
/** * Process a Connection Lost notification * * @param data */ private void connectionLostAction(Bundle data) { if (callback != null) { Exception reason = (Exception) data .getSerializable(MqttServiceConstants.CALLBACK_EXCEPTION); callback.connectionLost(reason); } }
/** * Process a Connection Lost notification * * @param data */ private void connectionLostAction(Bundle data) { if (callback != null) { Exception reason = (Exception) data .getSerializable(MqttServiceConstants.CALLBACK_EXCEPTION); callback.connectionLost(reason); } }
public void connectionLost(Throwable cause) { if (automaticReconnect) { Log.i(MqttAsyncClient.class.getName(),"lost"); // Automatic reconnect is set so make sure comms is in resting // state comms.setRestingState(true); reconnecting = true; startReconnectCycle(); if(mqttCallback!=null) mqttCallback.connectionLost(cause); } }
@Test public void testLostConnectUserDisconnect() throws Exception { MockMqttClient mockClient = new MockMqttClient(); AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); testClient.setMqttClient(mockClient); TestClientStatusCallback csb = new TestClientStatusCallback(); KeyStore testKeystore = AWSIotKeystoreHelper.getIotKeystore(CERT_ID, KEYSTORE_PATH, KEYSTORE_NAME, KEYSTORE_PASSWORD); testClient.connect(testKeystore, csb); mockClient.mockConnectSuccess(); assertEquals(1, mockClient.connectCalls); assertTrue(mockClient.mostRecentOptions.isCleanSession()); testClient.disconnect(); mockClient.mockCallback.connectionLost(new Exception("test")); assertEquals(1, mockClient.connectCalls); } /*
/** * Process a notification that we have disconnected * * @param data */ private void disconnected(Bundle data) { clientHandle = null; // avoid reuse! IMqttToken token = removeMqttToken(data); if (token != null) { ((MqttTokenAndroid) token).notifyComplete(); } if (callback != null) { callback.connectionLost(null); } }
/** * Process a notification that we have disconnected * * @param data */ private void disconnected(Bundle data) { clientHandle = null; // avoid reuse! IMqttToken token = removeMqttToken(data); if (token != null) { ((MqttTokenAndroid) token).notifyComplete(); } if (callback != null) { callback.connectionLost(null); } }
@Override public void connectionLost(Throwable cause) { LOGGER.warn("MQTT connection lost for client: {}", mqttClient.getClientId(), cause); switch (clientDefinition.getConfig().getReconnectionMode()) { case NONE: break; case CUSTOM: if (publisherKey != null) { injector.getInstance(publisherKey).connectionLost(cause); } if (listenerKey != null) { injector.getInstance(listenerKey).connectionLost(cause); } break; case ALWAYS: default: LOGGER.debug("reconnecting MQTT client {}", mqttClient.getClientId(), cause); reconnect(); break; } }
/** * This method is called when the connection to the server is lost. If there * is no cause then it was a clean disconnect. The connectionLost callback * will be invoked if registered and run on the thread that requested * shutdown e.g. receiver or sender thread. If the request was a user * initiated disconnect then the disconnect token will be notified. * * @param cause the reason behind the loss of connection. */ public void connectionLost(MqttException cause) { final String methodName = "connectionLost"; // If there was a problem and a client callback has been set inform // the connection lost listener of the problem. try { if (mqttCallback != null && cause != null) { // @TRACE 708=call connectionLost log.fine(className, methodName, "708", new Object[] { cause }); mqttCallback.connectionLost(cause); } } catch (java.lang.Throwable t) { // Just log the fact that a throwable has caught connection lost // is called during shutdown processing so no need to do anything else // @TRACE 720=exception from connectionLost {0} log.fine(className, methodName, "720", new Object[] { t }); } }
/** * This method is called when the connection to the server is lost. If there * is no cause then it was a clean disconnect. The connectionLost callback * will be invoked if registered and run on the thread that requested * shutdown e.g. receiver or sender thread. If the request was a user * initiated disconnect then the disconnect token will be notified. * * @param cause the reason behind the loss of connection. */ public void connectionLost(MqttException cause) { final String methodName = "connectionLost"; // If there was a problem and a client callback has been set inform // the connection lost listener of the problem. try { if (mqttCallback != null && cause != null) { // @TRACE 708=call connectionLost log.fine(CLASS_NAME, methodName, "708", new Object[] { cause }); mqttCallback.connectionLost(cause); } if(reconnectInternalCallback != null && cause != null){ reconnectInternalCallback.connectionLost(cause); } } catch (java.lang.Throwable t) { // Just log the fact that a throwable has caught connection lost // is called during shutdown processing so no need to do anything else // @TRACE 720=exception from connectionLost {0} log.fine(CLASS_NAME, methodName, "720", new Object[] { t }); } }
/** * This method is called when the connection to the server is lost. If there * is no cause then it was a clean disconnect. The connectionLost callback * will be invoked if registered and run on the thread that requested * shutdown e.g. receiver or sender thread. If the request was a user * initiated disconnect then the disconnect token will be notified. * * @param cause the reason behind the loss of connection. */ public void connectionLost(MqttException cause) { final String methodName = "connectionLost"; // If there was a problem and a client callback has been set inform // the connection lost listener of the problem. try { if (mqttCallback != null && cause != null) { // @TRACE 708=call connectionLost log.fine(CLASS_NAME, methodName, "708", new Object[] { cause }); mqttCallback.connectionLost(cause); } if(reconnectInternalCallback != null && cause != null){ reconnectInternalCallback.connectionLost(cause); } } catch (Throwable t) { // Just log the fact that a throwable has caught connection lost // is called during shutdown processing so no need to do anything else // @TRACE 720=exception from connectionLost {0} log.fine(CLASS_NAME, methodName, "720", new Object[] { t }); } }