[AIX][Windows][Linux]

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.

Procedure

  1. Has another client started that used the same ClientIdentifier ?

    If a second client is started, or the same client is restarted, using the same ClientIdentifier, the first connection to the first client is dropped.

  2. Has the client accessed a topic that it is not authorized to publish or subscribe to?

    Any actions the telemetry service takes on behalf of a client that return MQCC_FAIL result in the service dropping the client connection.

    The reason code is not returned to the client.
    • Look for log messages in the mqxr.log and AMQERR01.LOG files for the queue manager the client is connected to; see Server-side logs.
  3. Has the TCP/IP connection dropped?

    A firewall might have a low timeout setting for marking a TCPIP connection as inactive, and dropped the connection.

    • Shorten the inactive TCPIP connection time using MqttConnectOptions.setKeepAliveInterval.