Common mosquitto_sub errors when connecting to your MQTT broker and how to fix them


#1

Here is a list of known errors that you can get while connecting with mosquitto_sub. The following indications use -d (–debug) option to get more verbose output.

Consider the following indications.

  1. Firewall in place. If you run mosquitto_sub with -d option (–debug) and get no single
    line of output like this:

    >> mosquitto_sub -d -h node02.myqtthub.com  -i myHubxxxxIdMosq -u myHubxxxxIdMosqUsr -P xxxx -t message/topic/to/subscribe -q 2
    (command issued, waiting and without showing no input)
    

    Then check your connection see if some firewall is blocking 1883/tcp or 8883/tcp.

  2. DNS problem. If you run your mosquitto_sub with -d option (–debug) and there is a DNS
    o route gateway problem, you will get something like:

    >> mosquitto_sub -d -h node02.myqtthub.com  -i myHubxxxxIdMosq -u myHubxxxxIdMosqUsr -P xxxx -t message/topic/to/subscribe -q 2 
    Unable to connect (Lookup error.).
    
  3. Missing default route gateway. If you run your mosquitto_sub with -d option (–debug) and without
    a default route gateway, you will get the following error:

    >>> mosquitto_sub -d -h node02.myqtthub.com  -i myHubxxxxxxIdMosq -u myHubxxxxxxIdMosqUsr -P xxxxx -t message/topic/to/subscribe -q 2 
    Error: Network is unreachable
    
  4. Wrong clientId, userName or password. If you run your mosquitto_sub with -d option (–debug) and using wrong clientId, userName or password,
    you will get:

    >> mosquitto_sub -d -h node02.myqtthub.com  -i myHubxxxxxxIdMosq -u myHubxxxxxxIdMosqUsr -P test1234f -t message/topic/to/subscribe -q 2 
    Client myHubxxxxxxIdMosq sending CONNECT
    Client myHubxxxxxxIdMosq received CONNACK (3)
    Connection Refused: broker unavailable.
    Client myHubxxxxxxIdMosq sending DISCONNECT
    
    
  5. Output expected. If you run your mosquitto_sub with --debug, you should get the following
    if you connect without any issue:

    >> mosquitto_sub -d -h node02.myqtthub.com  -i myHubxxxxIdMosq -u myHubxxxxIdMosqUsr -P xxx -t message/topic/to/subscribe -q 2 
    Client myHubxxxxxxIdMosq sending CONNECT
    Client myHubxxxxxxIdMosq received CONNACK (0)
    Client myHubxxxxxxIdMosq sending SUBSCRIBE (Mid: 1, Topic: message/topic/to/subscribe, QoS: 2)
    Client myHubxxxxxxIdMosq received SUBACK
    Subscribed (mid: 1): 2
    Client myHubxxxxxxIdMosq sending PINGREQ
    Client myHubxxxxxxIdMosq received PINGRESP
    Client myHubxxxxxxIdMosq sending PINGREQ
    Client myHubxxxxxxIdMosq received PINGRESP
    

How to send and receive messages with mosquitto_sub and mosquitto_pub to MyQttHub.com
MyQttHub EN -- Start here
Sonoff "mini" with Tasmota 6.5.0 seems to have a problem with MyQttHub