client.disconnect(); client.disconnect(disconnectQuiesceTimeout);
public void shutdown() { try { myClient.disconnect(); } catch (MqttException e) { log.warn("Could not disconnect MQTT client for name: " + myConfig.getName() + " and ip: " + myConfig.getIp()); } myClient = null; } }
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); } }
sampleClient.publish(topic, message); log.info("Message published"); sampleClient.disconnect(); log.info("Disconnected"); System.exit(0);
@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() ); } } }
@Test public void checkSupportSSLForMultipleClient() throws Exception { LOG.info("*** checkSupportSSLForMultipleClient ***"); SSLSocketFactory ssf = configureSSLSocketFactory(); MqttConnectOptions options = new MqttConnectOptions(); options.setSocketFactory(ssf); m_client.connect(options); m_client.subscribe("/topic", 0); MqttClient secondClient = new MqttClient("ssl://localhost:8883", "secondTestClient", new MemoryPersistence()); MqttConnectOptions secondClientOptions = new MqttConnectOptions(); secondClientOptions.setSocketFactory(ssf); secondClient.connect(secondClientOptions); secondClient.publish("/topic", new MqttMessage("message".getBytes(UTF_8))); secondClient.disconnect(); m_client.disconnect(); }
assertEquals("Hello world MQTT!!", new String(messageOnA.getPayload(), UTF_8)); assertEquals(1, messageOnA.getQos()); subscriberA.disconnect(); assertEquals("Hello world MQTT!!", new String(messageOnB.getPayload(), UTF_8)); assertEquals(2, messageOnB.getQos()); subscriberB.disconnect();
@Override public void disconnect() { if (client != null) { try { client.disconnect(); } catch (MqttException e) { // disconnect silently } } }
public void unsubscribeFromTopic() { if(mqttClient != null) { try { mqttClient.disconnect(); } catch (MqttException e) { log.error("Error while closing the MQTTClient connection", e); } } }
@Override public void shutdown() { if (null != mqttClient) { try { mqttClient.disconnect(); System.out.println("Disconnected"); } catch (MqttException ex) { log.error("Error in disconnect", ex); } } } }
@PreDestroy public void close() throws MqttException{ try { client.disconnect(); } catch(Exception e) {} try { client.close(); } catch(Exception e) {} } }
@Override public void dispose() { try { client.disconnect(); client.close(); } catch (MqttException e) { logger.warn("Error while closing the MQTT client.", 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 close() throws IOException { if (mqttClient != null) { try { mqttClient.close(); mqttClient.disconnect(); } catch (MqttException e) { throw new IOException(e); } } }
/** * Shutdown the mqtt client. Call this whenever the system exits, test cases are finished or disconnect hook is * called. * * @throws MqttException */ public void disconnect() throws MqttException { if (isConnected()) { mqttClient.disconnect(); log.info("Client " + mqttClientID + " Disconnected"); } }
@Override protected synchronized void doDisconnect(MqttClient client) throws Exception { if (client.isConnected()) client.disconnect(); }
// Construct the MqttClient instance MqttClient client = new MqttClient(brokerUrl, clientId); // Set this wrapper as the callback handler client.setCallback(this); // Connect to the server client.connect(); // Disconnect the client client.disconnect();
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); } }