When the connection to the MQTT server fails the button on the Sonoff Touch / S20 becomes unresponsive. The buttons still works -sometimes- but starts to 'hang' regularly. This is probably because it's caught in the loop of trying to reach the MQTT server and therefor cannot handle the button press.
It would be very convenient if Tasmota could deal with a broken MQTT connection better. So that when there's is a problem with the network the physical Sonoff Touch button still works properly.
It removes a single point of failure and keeps me from having to explain to my girlfriend that she cannot switch the lights because there's a problem with my MQTT server 馃槄
There is a bug in the TCP library that tasmota uses, when it is attempting to
establish a new connection, everything stops for up to 5 seconds.
Please check the latest mqtt library @arendst update it few days ago.
@davidelang, do you have any info about the bug in the TCP library?
just that during the timeout while it trying to connect, it is waiting, so
nothing else can take place during that time.
They are 'not waiting correctly', that is, they are not releasing the CPU so
that other things can run during this time. This is probably not a trivial fix
because there is probably a lot of software out there now that assumes that the
other stuff won't run until you have a connection. Tasmota has a lot of stuff
that's interrupt driven (button presses, timers, etc), and the main loop that
we want to have continue to run while the connection is being established, so
they probably are going to need to create a new function that starts the
connection, and has a callback to execute when they get the connection, and
another callback to execute if the connection fails
any progress on this? My girlfriend is driving me nuts because the switch is sometimes unresponsive. Is the mqtt server the problem? I am using Alexa to control the switch.
would a separate mqtt server (RPi with wired connection) help in any way?
EDIT: Is it possible to get the device to first toggle the relay and afterwards try to send the mqtt message?
In no particular order:
1) Get a new girlfriend
2) Disable MQTT
3) Use command MqttRetry to increase retry time
Check the Other Configuration tab:

This is not something the tasmota project can solve, it's a bug in the Arduino
TCP library. While it is attempting to establish a connection, nothing else on
the device will work.
If you are connecting to a cloud MQTT server, switching to a local one on your
network would significantly increase your reliability.
Wow, could have seen that myself!... Thanks a lot, seems like it works now.
EDIT: yes I read about that in the first comments, but isn't it fixable in the library? Guess its not a simple task to do, but I guess someone on github must have solved it already
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem.
Most helpful comment
In no particular order:
1) Get a new girlfriend
2) Disable MQTT
3) Use command
MqttRetryto increase retry time