Resolving problem: MQTT client connection dropped
Find out what is causing a client to throw unexpected ConnectionLost exceptions after successfully connecting and running for either a short or long while.
Before you begin
The MQTT client has connected successfully. The client might be up for a long while. If clients are starting with only a short interval between them, the time between connecting successfully and the connection being dropped might be short.
It is not hard to distinguish a dropped connection from a connection that was successfully made, and then later dropped. A dropped connection is defined by the MQTT client calling the MqttCallback.ConnectionLost method. The method is only called after the connection has been successfully established. The symptom is different to MqttClient.Connect throwing an exception after receiving a negative acknowledgment or timing out.
If the MQTT client application is not using the MQTT client libraries supplied by IBM® MQ, the symptom depends on the client. In the MQTT v3 protocol, the symptom is a lack of timely response to a request to the server, or the failure of the TCP/IP connection.
About this task
The MQTT client calls MqttCallback.ConnectionLost with a throwable exception in response to any server-side problems encountered after receiving a positive connection acknowledgment. When an MQTT client returns from MqttTopic.publish and MqttClient.subscribe the request is transferred to an MQTT client thread that is responsible for sending and receiving messages. Server-side errors are reported asynchronously by passing a throwable exception to the ConnectionLost callback method.