Will the active MQTT client need to close the connection in case of exception

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Will the active MQTT client need to close the connection in case of exception

Nevadita
Hi,
    I am writing a code in which i have used Active MQTT client with ssl.
The case in which my TCP connection is made and my Ssl handshake fails. The
serverside broker is left with many CLOSE_WAIT state connections. Do I need
to disconnect and close my client if exception this case occures.

Below is a sample snippet of my code:

private MqttClient client;

boolean connectSubscriber() throws Exception {
                MqttSmpClient.logger.info("MqttSmpClient.connectSubscriber : Connect
subscriber");
                if (client != null && !client.isConnected()) {
                        try {

                                client.connect(mqttOptions);
                                MqttSmpClient.logger.info("MqttSmpClient.connectSubscriber : Subscriber
connected for clientId {}",
                                                clientId);
                                mqttServiceListener.onConnectivityChange(MqttServiceListener.CONNECTED);
                        } catch (final Exception exc) {
                                MqttSmpClient.logger.error("MqttSmpClient.connectSubscriber : Mqtt
connection failed. Retrying : {}",
                                                exc.getMessage());
                                MqttSmpClient.logger.debug("MqttSmpClient.connectSubscriber : Mqtt
connection failed. Retrying : ",
                                                exc);
*
                                    client.disconnect();
                                    client.close();
*
                                throw exc;
                        }





--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html