/** * @return if the connection between remote client and local endpoint is established/open */ public boolean isConnected() { boolean ret = delegate.isConnected(); return ret; }
/** * @return if the connection between remote client and local endpoint is established/open */ public boolean isConnected() { boolean ret = delegate.isConnected(); return ret; }
/** * @return if the connection between remote client and local endpoint is established/open */ public boolean isConnected() { boolean ret = delegate.isConnected(); return ret; }
/** * Closes a connection to a client. * * @param endpoint The connection to close. * @param authenticatedDevice Optional authenticated device information, may be {@code null}. */ protected final void close(final MqttEndpoint endpoint, final Device authenticatedDevice) { onClose(endpoint); sendDisconnectedEvent(endpoint.clientIdentifier(), authenticatedDevice); if (authenticatedDevice == null) { LOG.debug("connection to anonymous device [clientId: {}] closed", endpoint.clientIdentifier()); metrics.decrementUnauthenticatedConnections(); } else { LOG.debug("connection to device [tenant-id: {}, device-id: {}] closed", authenticatedDevice.getTenantId(), authenticatedDevice.getDeviceId()); metrics.decrementConnections(authenticatedDevice.getTenantId()); } if (endpoint.isConnected()) { LOG.debug("closing connection with client [client ID: {}]", endpoint.clientIdentifier()); endpoint.close(); } else { LOG.trace("client has already closed connection"); } }
if (endpoint.isConnected()) { endpoint.unsubscribeAcknowledge(unsubscribeMsg.messageId());
.collect(Collectors.toList()); if (endpoint.isConnected()) { endpoint.subscribeAcknowledge(subscribeMsg.messageId(), grantedQosLevels);
.collect(Collectors.toList()); if (endpoint.isConnected()) { endpoint.subscribeAcknowledge(subscribeMsg.messageId(), grantedQosLevels);
metrics.decrementConnections(authenticatedDevice.getTenantId()); if (endpoint.isConnected()) { LOG.debug("closing connection with client [client ID: {}]", endpoint.clientIdentifier()); endpoint.close();
if (endpoint.isConnected()) { endpoint.unsubscribeAcknowledge(unsubscribeMsg.messageId());
@Test public void connected(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(); context.assertTrue(client.isConnected() && this.endpoint.isConnected()); } catch (MqttException e) { context.assertTrue(false); e.printStackTrace(); } }
@Test public void connected(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(); context.assertTrue(client.isConnected() && this.endpoint.isConnected()); } catch (MqttException e) { context.assertTrue(false); e.printStackTrace(); } }
metrics.incrementCommandResponseDeliveredToApplication(targetAddress.getTenantId()); if (ctx.deviceEndpoint().isConnected() && ctx.message().qosLevel() == MqttQoS.AT_LEAST_ONCE) { ctx.deviceEndpoint().publishAcknowledge(ctx.message().messageId());
metrics.incrementCommandResponseDeliveredToApplication(targetAddress.getTenantId()); if (ctx.deviceEndpoint().isConnected() && ctx.message().qosLevel() == MqttQoS.AT_LEAST_ONCE) { ctx.deviceEndpoint().publishAcknowledge(ctx.message().messageId());
ctx.message().topicName(), ctx.message().qosLevel(), tenant, deviceId); if (ctx.isAtLeastOnce() && ctx.deviceEndpoint().isConnected()) { currentSpan.log("sending PUBACK"); ctx.acknowledge();
ctx.message().topicName(), ctx.message().qosLevel(), tenant, deviceId); if (ctx.deviceEndpoint().isConnected() && ctx.message().qosLevel() == MqttQoS.AT_LEAST_ONCE) { currentSpan.log("sending PUBACK"); ctx.deviceEndpoint().publishAcknowledge(ctx.message().messageId());
@Test public void disconnectedByClient(TestContext context) { Async async = context.async(); 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.disconnect(); // give more time to the MqttClient to update its connection state this.vertx.setTimer(1000, t1 -> { async.complete(); }); async.await(); context.assertTrue(!client.isConnected() && !this.endpoint.isConnected()); } catch (MqttException e) { context.assertTrue(false); e.printStackTrace(); } }
@Test public void disconnectedByClient(TestContext context) { Async async = context.async(); 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.disconnect(); // give more time to the MqttClient to update its connection state this.vertx.setTimer(1000, t1 -> { async.complete(); }); async.await(); context.assertTrue(!client.isConnected() && !this.endpoint.isConnected()); } catch (MqttException e) { context.assertTrue(false); e.printStackTrace(); } }
@Test public void disconnectedByServer(TestContext context) { Async async = context.async(); try { MemoryPersistence persistence = new MemoryPersistence(); MqttClient client = new MqttClient(String.format("tcp://%s:%d", MQTT_SERVER_HOST, MQTT_SERVER_PORT), "12345", persistence); client.connect(); // the local endpoint closes connection after a few seconds this.vertx.setTimer(1000, t -> { this.endpoint.close(); // give more time to the MqttClient to update its connection state this.vertx.setTimer(1000, t1 -> { async.complete(); }); }); async.await(); context.assertTrue(!client.isConnected() && !this.endpoint.isConnected()); } catch (MqttException e) { context.assertTrue(false); e.printStackTrace(); } }
@Test public void disconnectedByServer(TestContext context) { Async async = context.async(); try { MemoryPersistence persistence = new MemoryPersistence(); MqttClient client = new MqttClient(String.format("tcp://%s:%d", MQTT_SERVER_HOST, MQTT_SERVER_PORT), "12345", persistence); client.connect(); // the local endpoint closes connection after a few seconds this.vertx.setTimer(1000, t -> { this.endpoint.close(); // give more time to the MqttClient to update its connection state this.vertx.setTimer(1000, t1 -> { async.complete(); }); }); async.await(); context.assertTrue(!client.isConnected() && !this.endpoint.isConnected()); } catch (MqttException e) { context.assertTrue(false); e.printStackTrace(); } }