-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MQTT lost connection problem happen after Wifi router restart. #3314
Comments
TASMOTA develop many function in FW but it's still unstable. some function very simple for example "Wifi connection", "MQTT connection" it's still having problem so far. |
Hi Wongnam, |
If you search the issues list in the esp8266 arduino repo you will find MANY related to WiFi. Tasmota uses that code, which in turn is based on the code/SDK from espressif. All of the released libraries have some issues. Some of the issues are so severe they make it unusable, but only under certain conditions. There is a new release of the core scheduled for August 1. It will likely take awhile before there is the ability to use it with Tasmota. Hopefully, 2.4.2 will be better than 2.4.0, which is worse than 2.3.0. |
@Frogmore42 I think you've read the article not carefully. We said that the web server in TASMOTA was reachable(even Alexa can control the sonoff normaly) so it's not related to wifi communication issue as you mention about. please do not assume Wifi issue here. @nosaj66au you are right, you descripted the exactly the same issue that my sonoff devices are facing.
|
My comment was in reference to the comment about WiFi instability. But, the issues with WiFi, which is networking can indeed impact MQTT. You are correct that since the web console is working it seems WiFi is fine and it might actually be fine. You might also be right that there is a problem with MQTT not reconnecting properly. If so, that is probably caused by the underlying MQTT code, but could be due to the way Tasmota is using it. It could be that once WiFi is reliable, the MQTT issue will become nearly impossible to hit. I have never had an issue with MQTT not connecting. That doesn't mean there isn't an issue. It could be the changes in 6.x make it more likely to occur. What I am saying is that since there are know strange issues with WiFi that could be causing the problem and there is a release of the core scheduled soon, it is like best to wait till that is integrated and see if it addresses the issue. If it doesn't, then someone will need to take the time to understand what exactly is failing and why. I doubt that would be a simple task. Since you are using a non default mode for WiFi (no restart) it is possible that the mqtt code only tries once. If it fails, no more mqtt. Other people wouldn't see this, since when WiFi goes out their devices restart. It is easy to complain about the quality of something. It is much harder to do something constructive to improve it. |
OK Guys Checked my notes from when compiling 6.0.0.a and found I used the Tasmota alternative MQTT lib, however when compiling the 5.12.0i I didn't. So now have gone back to 5.14 release with the original lib. I'll run this for a few day see what happens. I did have a case today with a MQTT dropout at 80% wifi signal. The Unifi software did not report loss of device. So I'm rethinking some of my earlier Wifi theories. Jason |
I have been running well over 24hours now without a failure. I not doing to call it yet but so far so good. |
I want to add that I have the same issue. As of the previous version where we could select an alternative MQTT lib, after a few days I find my devices cant be switched via MQTT until a reboot. I have tried TASMOTA_MQTT and well as the other ESP mqtt one. Both have the same issues. Of course, pubsubclient works well, but sucks because of the switch delay wich is untenable as I have sonoffs wired as all my house lights. I was unable to determine what causes this issue except that it is inevitable after a few days. I think that it's possible my wifi router reboots itself / drops the signal. Perhaps the interrupt for wifi reconnect isn't reliable and so mqtt doesn't reconnect properly? Here's my status 0 of one that is currently not responding: 04:23:03 CMD: status 0 I'm pretty sure I've also tested with both Arduino version 2.3 and 2.4.1 but I can't remember.. Perhaps my wifi router is overloaded haha |
@uberflyx the issue is due to FW does not reconnect to MQTT broker sometimes until it is restart. |
Me again, |
Hi Jason and All, These are the experiences I've had before with the TASMOTA fw configuration as below:
Do you see this is the endless loop that I have experienced through. Thanks. |
You are right. Very well written. Thanks. We have to look to that. In my setup, I use last version with wificonfig 5, TasmotaMQTT in esplib 2.3.0 My sonoffs connects to the embedded broker of Home Assistant and if I turn off my router or I reset my raspberry pi, my devices reconnect to my home assistant but only because I have an startup script in HA to ask for status to all sonoffs as explained in the wiki in the home assistant chapter. So, I don't know if in your case, your Tasmotas connects to your broker but not send information to your home automation software, or if they ignore the startup of your broker. Please, Can you confirm which case is using weblog 4 in your console? |
@ascillato I use MQTT Broker and Node-red in the same Pi 3B+. I do not use HA |
Ok Let's try this to know what is happening in your case. Using wificonfig 5,
And share your console log. If Tasmota is not connected to the MQTT broker, when toggling it should say RSL:, if connected it should say MQT: |
|
|
Here you are: (i am out of my house, i use VPN to perform as you request. i can not touch the button yet.) |
The log shows that your device is connected to your mqtt broker again. Your issue is that your node-red is not updating the LWT information. Exactly the same was happening to me but in home assistant. So, I add an automation in my Home Assistant to ask again for status to the grouptopic of all my Tasmotas (cmnd/sonoffs/POWER) |
@ascillato I did the same as your idea so far but no MQTT response back from devices. |
@ascillato I would like to perform the test one more time(as the last time the device auto roam to my upstair 2nd AP), so i disable the Radio of my up stair 2nd AP now, i use only 1 AP from my router. Result: MQTT still lost after turn off/on router AP. Here is the log: |
Hi again, |
Yep, pubsubclient MQTT Lib has limited issue |
@wongnam How did you create that page? |
@webxl your comment is not related to my topic. |
Have you find any solution? have you tried other MQTT library? |
@ascillato2 |
Your findings are very useful to search for the bug. Thanks for share. |
Summary: If restarting the wifi router, and you have Tasmota_MQTT Library with The rule With any other combination (restarting MQTT Broker or using pubsubclient library or using |
Fixed with PR #3558 Please test it. Thanks |
I’ve just recompiled as your advice. I test it now, will revert you back for the result. Thanks |
@ascillato I can confirm that the issue is gone and all my Tasmota devices are stick to mqtt broker now. Thank you. |
My sonoff basic, sonoff touch, RF bridge are facing issue with MQTT not reconnect after i restart my wifi router.
All my Sonoff devices are using Tasmota version 6.1.1b, core 2.30, MQTT_ESPMQTTARDUINO, self compile by VSC.
symptom:
10:23:04 CMD: status 0
10:23:04 MQT: stat/mypc/STATUS = {"Status":{"Module":1,"FriendlyName":["My PC"],"Topic":"mypc","ButtonTopic":"0","Power":0,"PowerOnState":3,"LedState":1,"SaveData":1,"SaveState":1,"ButtonRetain":0,"PowerRetain":0}}
10:23:04 MQT: stat/mypc/STATUS1 = {"StatusPRM":{"Baudrate":115200,"GroupTopic":"sonoffs","OtaUrl":"http://sonoff.maddox.co.uk/tasmota/sonoff.bin","RestartReason":"Software/System restart","Uptime":"5T15:17:53","StartupUTC":"2018-07-18T12:05:11","Sleep":0,"BootCount":4,"SaveCount":9,"SaveAddress":"FB000"}}
10:23:04 MQT: stat/mypc/STATUS2 = {"StatusFWR":{"Version":"6.1.1b","BuildDateTime":"2018-07-18T17:42:33","Boot":31,"Core":"2_3_0","SDK":"1.5.3(aec24ac9)"}}
10:23:04 MQT: stat/mypc/STATUS3 = {"StatusLOG":{"SerialLog":2,"WebLog":2,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["Multimedia Wi-Fi Network","Wong"],"TelePeriod":300,"SetOption":["00008009","55A18000"]}}
10:23:04 MQT: stat/mypc/STATUS4 = {"StatusMEM":{"ProgramSize":417,"Free":584,"Heap":17,"ProgramFlashSize":1024,"FlashSize":1024,"FlashMode":3,"Features":["00000809","0F083380","0C000000","00000096","00000000"]}}
10:23:04 MQT: stat/mypc/STATUS5 = {"StatusNET":{"Hostname":"mypc-6980","IPAddress":"192.168.12.148","Gateway":"192.168.12.1","Subnetmask":"255.255.255.0","DNSServer":"192.168.12.1","Mac":"68:C6:3A:95:9B:44","Webserver":2,"WifiConfig":5}}
10:23:04 MQT: stat/mypc/STATUS6 = {"StatusMQT":{"MqttHost":"192.168.12.155","MqttPort":1883,"MqttClientMask":"DVES_%06X","MqttClient":"DVES_959B44","MqttUser":"admin","MqttType":3,"MAX_PACKET_SIZE":1000,"KEEPALIVE":15}}
10:23:04 MQT: stat/mypc/STATUS7 = {"StatusTIM":{"UTC":"Tue Jul 24 03:23:04 2018","Local":"Tue Jul 24 10:23:04 2018","StartDST":"Sun Mar 25 02:00:00 2018","EndDST":"Sun Oct 28 03:00:00 2018","Timezone":7,"Sunrise":"05:40","Sunset":"18:18"}}
10:23:04 MQT: stat/mypc/STATUS10 = {"StatusSNS":{"Time":"2018-07-24T10:23:04"}}
10:23:04 MQT: stat/mypc/STATUS11 = {"StatusSTS":{"Time":"2018-07-24T10:23:04","Uptime":"5T15:17:53","Vcc":3.174,"POWER":"OFF","Wifi":{"AP":1,"SSId":"Multimedia Wi-Fi Network","RSSI":62,"APMac":"B0:C7:45:36:85:E0"}}}
The text was updated successfully, but these errors were encountered: