Skip to main content
Version: Next

Mosquitto Client Connection Debugging Guide

Network Layer Checks

Test with nmap

nmap -p [port] [broker-host]

Scans the broker’s port to check if it is open and accepting connections, helping to detect firewall or routing issues.​

Test with telnet

telnet [broker-host] [port]

Attempts to open a TCP connection to the broker’s port. If the connection establishes (screen clears or prompt appears), the port is available and listening for connections.​

SSL/TLS Layer Checks (MQTTs / WSS)

MQTTs/SSL connection test

openssl s_client -connect [broker-host]:8883

With client certificate authentication

openssl s_client -connect [broker-host]:8883 -cert myclient.crt -key myclient.key

WSS (WebSocket Secure) with wscat

wscat -c wss://[broker-host]:[port]/mqtt

If you have configured a port to work via websockets, then regular debugging methods might fail. For WSS, use browser DevTools (Network tab) to observe the handshake and diagnose SSL errors.

Mosquitto Broker Logs and Configuration

Enable Logging to get information on what happens when a client connects and how the broker reacts on incoming connections from your client. Find the used clientid of your connection in the logs and make sure to check the timestamps to find the right connection to analyze.

Edit your mosquitto.conf:

Add the following to your mosquitto.conf file:

log_type all

The highest log level is now activated and very detailed logs on connections and packages are shown.

See more information on logging here