Advice on how to debug MQTT connection problem

160 views
Skip to first unread message

Andrew Fiddian-Green

unread,
Jul 25, 2020, 12:33:11 PM7/25/20
to TasmotaUsers
I am having a problem with a Tasmotized Sonoff not connecting to the MQTT broker, and would appreciate advice how to debug this.

The MQTT broker is Mosquitto running on a Raspberry Pi; I can successfully connect to it from various MQTT clients such as MQTT.fx, MQTT Explorer, and can subscribe and publish to it. I also have OpenHAB client Things connected to it, and they can also publish and subscribe. (So in other words, I have one MQTT broker and four different clients all singing from the same song book).

But then I also have a Tasmotized Sonoff TH16 which does NOT connect to the MQTT broker (see console log below).

16:44:43 MQT: Attempting connection...
16:44:47 MQT: Connect failed to 191.168.1.131:1883, rc -2. Retry in 10 sec

All clients (including the Sonoff) are set up identically as follows..

Host: 191.168.1.131 // NOTE: IP address rather than Host Name to avoid DNS issues
Port: 1883
User: myName
Pwd:  myPassword

The Sonoff is physically connected via 2.4GHz wi-fi, and the other clients are on Ethernet. All clients are on the same IP sub-net, and all clients received their IP addresses via DHCP (auto) from the same router. I can connect to the Sonoff via HTTP on its web server, so there is active routing between the Ethernet and Wi-Fi parts of the LAN (I even connected Wireshark and can see this traffic). The router is a Ubiquiti EdgeMax EdgeRouter Lite, and the Wi-Fi is via Ubiquiti UNIFI wireless access points.

I know that "rc -2" means "failed to connect". But why??


Andrew Fiddian-Green

unread,
Jul 26, 2020, 12:31:55 PM7/26/20
to TasmotaUsers
SOLVED: I was trying to connect to a wrong IP address 191.xx instead of 192.xx -- Doh!

Lester Bennett

unread,
Jul 26, 2020, 5:30:24 PM7/26/20
to TasmotaUsers
Isn't it amazing how you can keep looking at something like that and not see the mistake.
The mind sees what it expects to see.

Greg from Oz

unread,
Jul 26, 2020, 7:11:59 PM7/26/20
to TasmotaUsers
And that's why you copy and paste from a working example......been there done that.
Good it's working.

Reply all
Reply to author
Forward
0 new messages