private void stopMqttClient() { try { // Check if connected so subsequent calls does not produce an already stopped exception if ( !connectionError.get() && client.get() != null && client.get().isConnected() ) { log.logDebug( getString( PKG, "MQTTProducer.Log.Closing" ) ); client.get().disconnect(); client.get().close(); } } catch ( IllegalArgumentException | MqttException e ) { logError( e.getMessage() ); } }
@Override public void onClose() { try { this.mqttClient.close(); this.mqttClient.disconnect(); } catch (MqttException e) { DAO.severe("Error terminating the stream client for API request", e); } }
@Override public void close() { super.close(); try { // Check if connected so subsequent calls does not produce an already stopped exception if ( mqttClient != null && mqttClient.isConnected() ) { mqttClient.disconnect(); mqttClient.close(); } } catch ( MqttException e ) { mqttConsumer.logError( e.getMessage() ); } } }
client.close();
@Override public void dispose() { try { client.disconnect(); client.close(); } catch (MqttException e) { logger.warn("Error while closing the MQTT client.", e); } }
@PreDestroy public void close() throws MqttException{ try { client.disconnect(); } catch(Exception e) {} try { client.close(); } catch(Exception e) {} } }
@Override public void close() throws IOException { if (mqttClient != null) { try { mqttClient.close(); mqttClient.disconnect(); } catch (MqttException e) { throw new IOException(e); } } }
@Override public void close() { try { client.disconnect(); client.close(); closed = true; } catch (MqttException e) { logger.warn("Error while closing the MQTT client.", e); } }
@Override public void doClose(MqttClient client) throws Exception { try { doDisconnect(client); } finally { client.close(); } }
@Override public void disconnect() { try { client.disconnect(); log.debug("Disconnected from MQTT broker: " + brokerURL); } catch (MqttException e) { log.error("Could not disconnect from MQTT broker: " + brokerURL, e); } finally { try { client.close(); } catch (MqttException e) { log.error("Could not close connection with MQTT broker: " + brokerURL, e); } } }
public void disconnect() { try { client.disconnect(); log.debug("Disconnected from MQTT broker: " + brokerURL + " defined in Siddhi App: " + siddhiAppName); } catch (MqttException e) { log.error("Could not disconnect from MQTT broker: " + brokerURL + " defined in Siddhi App: " + siddhiAppName, e); } finally { try { client.close(); } catch (MqttException e) { log.error("Could not close connection with MQTT broker: " + brokerURL + " defined in Siddhi App: " + siddhiAppName, e); } } }
@Override public void destroy() throws ResourceException { try { theClient.disconnect(); theClient.close(); } catch (MqttException ex) { throw new ResourceException("Unable to close the MQTT client connection", ex); } }
void close() throws ResourceException { try { client.disconnect(); client.close(); } catch (MqttException ex) { throw new ResourceException("Unable to close the MQTT client", ex); } }
@Override public void close() { try { mqttClient.disconnect(); mqttClient.close(); } catch (MqttException e) { Logger.error(e, "Error: {}", e); } }
@Override public void close() { synchronized (monitor) { monitor.notifyAll(); } try { mqttClient.disconnect(); mqttClient.close(); } catch (MqttException e) { Logger.error(e, "Error: {}", e); } super.close(); }
@Override public void close() { synchronized (monitor) { monitor.notifyAll(); } try { mqttClient.disconnect(); mqttClient.close(); } catch (MqttException e) { Logger.error(e, "Error: {}", e); } super.close(); }
@Then("^Disconnect client with name \"(.*)\"$") public void disconnectClient(String clientName) throws Exception { MqttClient mqttClient = (MqttClient) stepData.get(clientName); if (mqttClient == null) { throw new Exception("Mqtt test client not found"); } try { mqttClient.disconnect(); mqttClient.close(); } catch (Exception e) { // Exception eaten on purpose. // Disconnect is for sanity only. } }
@Test public void bruteDisconnect(TestContext context) { try { MemoryPersistence persistence = new MemoryPersistence(); MqttClient client = new MqttClient(String.format("tcp://%s:%d", MQTT_SERVER_HOST, MQTT_SERVER_PORT), "12345", persistence); client.connect(); client.close(); context.assertTrue(false); } catch (MqttException e) { context.assertTrue(e.getReasonCode() == MqttException.REASON_CODE_CLIENT_CONNECTED); e.printStackTrace(); } }
@Test public void bruteDisconnect(TestContext context) { try { MemoryPersistence persistence = new MemoryPersistence(); MqttClient client = new MqttClient(String.format("tcp://%s:%d", MQTT_SERVER_HOST, MQTT_SERVER_PORT), "12345", persistence); client.connect(); client.close(); context.assertTrue(false); } catch (MqttException e) { context.assertTrue(e.getReasonCode() == MqttException.REASON_CODE_CLIENT_CONNECTED); e.printStackTrace(); } }