arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
22.08k stars 4.78k forks source link

MQT: Connect failed to IP:1883, rc 5. Retry in 10 sec #6428

Closed nightcat91 closed 5 years ago

nightcat91 commented 5 years ago

ISSUE DESCRIPTION - TROUBLESHOOTING

Freshly flashed MagicHome (Arilux) LC-02 RGBW Controller cant connect to MQTT Broker.

11:26:54 MQT: Connect failed to 10.11.11.1:1883, rc 5. Retry in 10 sec

I am using HomeAssistant Hassio Install on Linux with the "MQTT Server & Web client" addon for MQTT (v. 1.1.0 currently up to date). Each Tasmota device has a unique mqtt user and password and my broker does not allow anonymous: "allow_anonymous": false,

I have about 30-40 other Tasmota devices connected and working fine to this broker. Flashed with the same downloaded version of Tasmota compiled with the same compiler (Visual Code). So nothing I really changed from what I normally do.

This is the error message I can see in the log of the broker:

1568539874: New connection from 10.11.14.101 on port 1883.
1568539874: Socket error on client <unknown>, disconnecting.
1568539886: New connection from 10.11.14.101 on port 1883.
1568539886: Socket error on client <unknown>, disconnecting.
1568539898: New connection from 10.11.14.101 on port 1883.
1568539898: Socket error on client <unknown>, disconnecting.
Jason2866 commented 5 years ago

Sorry cant reproduce. Not a Tasmota issue. Try precompiled sonoff version.

nightcat91 commented 5 years ago

I tried an OTA Update using the sonoff-basic.bin (precompiled binary from the release page) -> did not help the issue Then I did a configuration reset -> did not help

I then reflashed the device using the sonoff-basic.bin (with wipe of the flash, this is done always by ESPHome Flasher) and went into its access point and typed in my wifi config. Went onto the web page and typed in the mqtt info, restarted and had the same problem:

00:00:06 MQT: Connect failed to 10.11.11.1:1883, rc 5. Retry in 10 sec

and the same log message in my mqtt broker:

1568552588: New connection from 10.11.2.229 on port 1883.
1568552588: Socket error on client <unknown>, disconnecting.
1568552597: New connection from 10.11.2.229 on port 1883.
1568552597: Socket error on client <unknown>, disconnecting.
1568552609: New connection from 10.11.2.229 on port 1883.
1568552609: Socket error on client <unknown>, disconnecting.
nightcat91 commented 5 years ago

Here is the whole serial log from the point of flashing the sonoff-basic.bin on the device

Leaving...
Hard Resetting...
Done! Flashing is complete!

Showing logs:
[15:01:18]r[15:01:18]00:00:00 CFG: Use defaults
[15:01:18]00:00:00 Project sonoff Sonoff Version 6.6.0(release-basic)-2_3_0
[15:01:18]00:00:00 WIF: WifiManager active for 3 minutes
[15:01:19]00:00:00 HTP: Web server active on sonoff-1024 with IP address 192.168.4.1
[15:01:57]00:00:39 WIF: Hostname %s-%04d, SSId1 NaitsabesNOT, SSId2 
[15:01:58]00:00:40 APP: Restarting
[15:01:58]
[15:01:58] ets Jan  8 2013,rst cause:1, boot mode:(3,7)
[15:01:58]
[15:01:58]load 0x4010f000, len 1384, room 16 
[15:01:58]tail 8
[15:01:58]chksum 0x2d
[15:01:58]csum 0x2d
[15:01:58]v60000608
[15:01:58]~ld
[15:01:58]
[15:01:58]00:00:00 CFG: Loaded from flash at F8, Count 4
[15:01:58]00:00:00 Project sonoff Sonoff Version 6.6.0(release-basic)-2_3_0
[15:01:59]00:00:00 WIF: Connecting to AP1 NaitsabesNOT in mode 11N as sonoff-1024...
[15:02:05]00:00:06 WIF: Connected
[15:02:05]00:00:06 HTP: Web server active on sonoff-1024 with IP address 10.11.2.229
[15:02:07]14:02:05 RSL: tele/sonoff/INFO1 = {"Module":"Sonoff Basic","Version":"6.6.0(release-basic)","FallbackTopic":"cmnd/DVES_1D8400_fb/","GroupTopic":"sonoffs"}
[15:02:07]14:02:05 RSL: tele/sonoff/INFO2 = {"WebServerMode":"Admin","Hostname":"sonoff-1024","IPAddress":"10.11.2.229"}
[15:02:07]14:02:05 RSL: tele/sonoff/INFO3 = {"RestartReason":"Software/System restart"}
[15:02:07]14:02:05 RSL: stat/sonoff/RESULT = {"POWER":"OFF"}
[15:02:07]14:02:05 RSL: stat/sonoff/POWER = OFF
[15:02:15]14:02:14 RSL: tele/sonoff/STATE = {"Time":"2019-09-15T14:02:14","Uptime":"0T00:00:16","Vcc":3.149,"Heap":18,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":39,"POWER":"OFF","Wifi":{"AP":1,"SSId":"NaitsabesNOT","BSSId":"3A:E8:29:9D:D5:94","Channel":9,"RSSI":80,"LinkCount":1,"Downtime":"0T00:00:06"}}
[15:03:08]14:03:07 RSL: tele/sonoff/LWT = 
[15:03:08]14:03:07 MQT: MqttHost 10.11.11.1, MqttPort 1883, MqttClient DVES_%06X, MqttUser magichome01, Topic magichome01, FullTopic %prefix%/%topic%/
[15:03:09]14:03:08 MQT: Attempting connection...
[15:03:09]14:03:08 MQT: Connect failed to 10.11.11.1:1883, rc 5. Retry in 10 sec
[15:03:10]14:03:09 APP: Restarting
[15:03:11]
[15:03:11] ets Jan  8 2013,rst cause:1, boot mode:(3,7)
[15:03:11]
[15:03:11]load 0x4010f000, len 1384, room 16 
[15:03:11]tail 8
[15:03:11]chksum 0x2d
[15:03:11]csum 0x2d
[15:03:11]v60000608
[15:03:11]~ld
[15:03:11]
[15:03:11]00:00:00 CFG: Loaded from flash at F5, Count 7
[15:03:11]00:00:00 Project sonoff Sonoff Version 6.6.0(release-basic)-2_3_0
[15:03:11]00:00:00 WIF: Connecting to AP1 NaitsabesNOT in mode 11N as magichome01-1024...
[15:03:16]00:00:04 WIF: Connected
[15:03:16]00:00:04 HTP: Web server active on magichome01-1024 with IP address 10.11.2.229
[15:03:18]00:00:06 MQT: Attempting connection...
[15:03:18]00:00:06 MQT: Connect failed to 10.11.11.1:1883, rc 5. Retry in 10 sec
[15:03:30]14:03:29 MQT: Attempting connection...
[15:03:30]14:03:29 MQT: Connect failed to 10.11.11.1:1883, rc 5. Retry in 10 sec
[15:03:42]14:03:41 MQT: Attempting connection...
[15:03:42]14:03:41 MQT: Connect failed to 10.11.11.1:1883, rc 5. Retry in 10 sec
[15:03:43]
Serial port closed!
arendst commented 5 years ago

See https://github.com/arendst/Sonoff-Tasmota/wiki/MQTT-Overview#status-codes

Check your mqttpassword.

nightcat91 commented 5 years ago

How did I not find that info page....bookmarked!

Very sorry for this!! There was indeed a mismatch in the username on the mqtt broker side.

Thanks for the help and sorry for the huge bug report for such a small issue

dirvo commented 3 years ago

I was using a very similar setup with hassio and Tasmota and got the rc5 code as well.

The problem was caused by the password not being complex enough (I had used just 1234 for testing). Once I changed to a complex password, the error went away. I haven't tested where exactly the limit is or why the simple password wasn't working, I'm just using a 32 char long key now and that works.

I'm leaving this here, In case anyone else has this problem, too.

ellnic commented 2 years ago

I had the opposite problem. I've never had the issue before with my own setup, but was recently helping a relative with a new HA installation. I could not get a single Sonoff Mini R2 to connect. The pass was a randomly generated 20 char ASCII. I changed to just upper, lower and numerical after reading this issue, and it resolved it!

Grupo-Atomos commented 2 years ago

I had the same problem. I did all the steps indicated in this post, however nothing worked. It only works when I downgrade the tasmota firmware to version 8.5.1. I suspect that the developer has enabled TLS of the updated version and so it is possible that the MQTT server does not accept the common port (I haven't tested this hypothesis yet!)

barbudor commented 2 years ago

If you are using TLS, you MUST use port 8883