---
schema_version: "1"
id: 25a7883afcf95cacee8219010a5d71a21f68328b5b5dcd324aaf1eaee4ae7392
title: Troubleshooting MQTT Connector
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/mqtt3-connector/latest/mqtt3-connector-troubleshooting.md
canonical_url: https://docs.mulesoft.com/mqtt3-connector/latest/mqtt3-connector-troubleshooting
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 84829101b2ecf5bbc3411dba3913e1b5884311294d01954bba5754a161236e93
description: MuleSoft Documentation Site
release: "1.1"
latest: true
---
---
product: MQTT Connector
version: 1.1
is-latest-version: true
---

# Troubleshooting MQTT Connector

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

To troubleshoot Anypoint Connector for MQTT (MQTT Connector), become familiar with the information
about enabling verbose logging and interpreting commonly thrown messages.

## Enable Verbose Logging

To enable verbose logging on the connector, you need to activate logging for the connector and for
the Eclipse Paho driver.

### Enable Verbose Logging for MQTT Connector

To enable verbose logging in the configuration file:

1.  Access Anypoint Studio and navigate to the **Package Explorer** view.

2.  Open your application’s project name.

3.  Open the `src/main/resources` path folder.

4.  Open the `log4j2.xml` file inside the folder.

5.  Add an `<AsyncLogger>` tag inside the `<Loggers>` tag:

    ```xml
    			<Loggers>
    				...
    				<AsyncLogger name="com.mulesoft.connectors.mqtt3" level="TRACE"/>
    				...
    			</Loggers>
    ```

6.  Save your application changes.

7.  Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule
    Application**.

### Enable Verbose Logging for Eclipse Paho Driver

Eclipse Paho, the underlying driver for MQTT Connector uses Java Util Logging. If you want to see
the driver’s log messages in the application’s log file, follow the next steps to provide your
application with the latest `log4j-jul-2.xx.x.jar` version:

1.  Identify the `log4j` core module version by checking the version suffix in the file name of
    `log4j-core-2.xx.x.jar` in `{MULE_HOME}/lib/boot`.

    For an embedded Mule runtime engine (Mule), find the folder that is similar to
    `{AnypointStudio Folder}/Contents/Eclipse/plugins/org.mule.tooling.server.4.3.0.ee_7.3.5.202005112043/mule/lib/boot`

2.  Download the same version of `log4j-jul-2.xx.x.jar` from the public Maven repository, for
    example, for Mule 4.3.0, it’s `log4j-jul-2.13.1.jar`.

3.  Put the `log4j-jul-2.xx.x.jar` into `{MULE_HOME}/lib/boot`.

4.  In the Mule app, add the corresponding `java.util.logging` category as per the logging level
    mapping documented on the
    [Apache Logging Services](https://logging.apache.org/log4j/2.3.x/log4j-jul/index.html) site, for
    example:

    ```xml
    `<AsyncLogger name="org.eclipse.paho.client.mqttv3.logging.JSR47Logger" level="ALL"/>`
    ```

    For the `level` attribute, you must provide a Java Util Logging Level. Check the
    [Apache Logging Services](https://logging.apache.org/log4j/2.3.x/log4j-jul/index.html)
    conversion table of Java Util Logging levels and its equivalent Log4j levels for further
    details.

## Enable Verbose Logging for Mosquitto Broker

Each broker has different mechanisms to configure logging. To set up a Mosquitto broker and
configure logging levels, follow these steps:

1.  Set up a Mosquitto broker by using the official Docker image. To do so, run the following
    command:

`docker run -it -p 1883:1883 \ -v /your/local/path/mosquitto.log:/mosquitto/mosquitto.log \ -v /your/local/path/mosquitto.conf:/mosquitto/config/mosquitto.conf eclipse-mosquitto`

By using this command, you supply the log file `mosquitto.log` and the configuration file
`mosquitto.conf`.

- The `mosquitto.log` is a file for the broker to write log messages to.

- The `mosquitto.conf` is the broker configuration file.

2.  Set the desired log level in the `mosquitto.conf` configuration file, for example:

    ```text
    # Unencrypted MQTT over TCP
    # for listener at port 1883
    listener 1883
    allow_anonymous true
    # =================================================================
    # Logging
    # =================================================================
    # Route log messages to log file
    log_dest file /mosquitto/mosquitto.log
    # Types of messages to log. Use multiple log_type lines for logging
    # multiple types of messages.
    log_type debug
    log_type error
    log_type warning
    log_type notice
    log_type information
    ```

In the first two lines of the previous file you set up a listener in port 1883, with no
authentication credentials required.

In the logging section you specify that the logs should be written to the `mosquitto.log` file that
you mounted, and that you want the broker to log messages of all levels.

You can add different listeners with different configurations, depending on what you need to test,
for example:

```text
per_listener_settings true

# Unencrypted MQTT over TCP
listener 1883
allow_anonymous true

# Unencrypted MQTT over TCP
listener 1884
password_file /mosquitto/config/mosquitto.passwd

listener 8080
protocol websockets
allow_anonymous true
```

In the previous file you configured 3 separate listeners:

- On port 1883 you specified an endpoint that allows anonymous connections over MQTT.

- On port 1884 you specified a password file where the broker expects to find the usernames and
  passwords for authentication.

- On port 8080 you specified that you will admit websockets connections.

To set each individual listener with separate configurations you must first set the
`per_listener_settings true`.

## Understand Common Throws

Here is a list of common throw messages and how to interpret them:

- MQTT3:CONNECTIVITY

  The client became disconnected from the broker while attempting to publish a message.

- MQTT3:INVALID\_TOPIC

  The topic is invalid because, for example, the name is too short, too long, or contains invalid
  characters.

- MQTT3:PERSISTENCE

  When publishing a message, an error occurred while reading or writing persistent data for reliable
  messaging.

- MQTT3:PUBLISH

  An error occurred while attempting to publish a message.

- MQTT3:RETRY\_EXHAUSTED

  All reconnection attempts failed.

- MQTT3:WRITE\_TIMEOUT

  An error occurred when the client timed out waiting to write messages to the server.

## See Also

- [Salesforce Help](https://help.salesforce.com)

- [Known Issues](https://help.salesforce.com/s/issues)
