Issues with connecting to MQTT with Tasmota

Hi, 

I am trying to hook up the tasmota smart plugs to control them via MQTT from your IAMMETER portal.

In the tasmota console it says connected, but on the IamMeter portal it's still offline. 


Here is the log from the tasmota console:


But on the IAMMETER portal it's still listed as "offline".


Here is also my MQTT config on tasmota.

What could be the issue?

Regards,

Martin



Thread Status
44
7355
7
5
0

Sort replies by:

Generally, mesh routing will not cause such problems. If you are convenient, you can send the model of mesh routing. We can test it if we have the opportunity.

Okay, I just tested teh same device with the same settings in another apartment and it works as it should. The only difference I see is that in my apartment I only have a router and in the house where I tried before I have TP Link routers with Wifi extenders and One Mesh function activated. Are you aware of any issues with Tasmota MQTT, when using Wifi Repeaters and/or Wifi Mesh technology?

Try to increase the MQTT_CLIENT_WIFI_TIMEOUT either by compiling customer firmware or by using MqttWifiTimeout command

Version 9.1.0.2 changed MQTT Wifi connection timeout from 5000ms to 200ms

pls empty User/Password (must do it),and change Full Topic:  device/%topic%/%prefix%/ 

then Click  Save

Okay, I just tried something else and downgraded the tasmota firmware from 9.5 down to 8.5.1 and now it works without problems. 
So it seems that the latest release of tasmota firmware has some kind of bug or something that prevents it from connecting to the MQTT server.

my soltion:

just set:

I set 1000ms, it can connect still and response time is OK as well... "MqttWifiTimeout 1000"


more

https://imeter.club/topic/402


thx 

I tried adjusting the settings as you suggested, but it still says failed to connect in the tasmota console:



pls empty User/Password (must do it),and change Full Topic:  device/%topic%/%prefix%/ then Click  Save

Do I need to open some port or something for this to work?

Does it really work without MQTT user, because it seems tasmota automatically always enters DVES_USER as MQTT user.

I delete username and password, but it is being filled automatically after saving. When I go back to configure, user and password has those default values again. 

Please make sure clear both username and password and click save.
This is enough.

The default userename and pwd will be appear when you refresh the page(I think this is introduced by the js code, not read from firmware configuration), but it does not mean the mqtt had used this username and password in communication.

I delete username and password, but it is being filled automatically after saving. When I go back to configure, user and password has those default values again. 

Okay, I tried this many time with empty user and password like below, but I still get MQT: connection failed:

I also tried just to test with the MQTT.fx and there it works and it shows online on the iammeter platform.

But with the Sonoff Basic with Tasmota firmware it doesn't work and it always says connection failed.

I think it has to do with the user and password, because on MQTT.fx I can specifically disable the function of user/password. But in tasmota I can only leave the fields empty, but it seems to always fill them with default values, which is something else than empty or not active user/password fields. 


Is there any dummy login or client user/password that I can enter in tasmota to test?

I also checked now, even when leaving user/password empty in the GUI and clicking save, later when checking in the console the values for user/password it defaults to the default values:


So it seems I need to enter some values for user/password on the tasmota gui to be able to connect to the iammeter MQTT broker. 

Okay, I just tested teh same device with the same settings in another apartment and it works as it should. The only difference I see is that in my apartment I only have a router and in the house where I tried before I have TP Link routers with Wifi extenders and One Mesh function activated. 

Are you aware of any issues with Tasmota MQTT, when using Wifi Repeaters and/or Wifi Mesh technology?



Okay, I am using the TP-Link Archer AX20 with RE300 repeaters in the house which are connected using their custom Onemesh protocol.
But I also tried already to disable that feature and I still had the connection problems with Tasmota plugs ot the MQTT server.

Another thought was, if having 5Ghz and 2.4GHz network could cause any problem with the tasmota MQTT connection? In TP-Link they also have a feature called "Smart connect", which combines 2.4GHz and 5GHz wifi network so that only one SSID is visible and then depending on the client's device capabilities it connects to 2.4GHz or to 5GHz. 

It doesn’t matter if 2.4G and 5G use a ssid. I tested it and it can be used.

Okay, i tested the sonoff basic with the same settings in my apartment in Kraków and it works. But in the house it says mqtt connection failed, even though the settings are the same. 


I also tried to connect from my laptop to the mqtt broker, using mqtt.fx and it also works normally in the house. 


So i don't know what else could be the reason. 


The only difference between apartment (where it works) and house (where it doesn't) work, is the internet provider. 

But as i can connect from my laptop to the mqtt broker out doesn't seem to be a blocked port or something like that. 


Other than that, there are the wifi repeaters with onemesh in the house. But even when i disable them and the onemesh, the sonoff still doesn't connect. 


Any idea what else i can try our test to narrow down the problem?

I actually went back to my apartment now to see if it still working, but now I get the same issue with the connection fail again, also in my apartment where it used to work before. 

I realized now also that this time, when saving the MQTT config on the Tasmota interface and putting the ClientID only as topic, then after the restart of the device and checking the settings, the topic defaults back to the Tasmota default value:


I don't know why this is happening now and why it wasn't before. Because before it worked with only having the client ID as topic. 
Now, if I put "device/clientID" into the topic field, it at least stores the value also after restart, but it still doesn't connect. (Of course I removed the "device" word from the full topic in this case. 


Somehow this Tasmota MQTT seems to work very unstable and I don't  know why. 

When connecting from the MQTT.fx windows tool to your IAMMETER broker, it all works without problem and it shows status online on your platform. But when using the Tasmota enabled IoT devices it's very unreliable and most of the time I can't get them to connect to your MQTT server. 


Have you noticed these kind of problems yourself or heard from other users as well? 


If your device is convenient for burning, it is recommended that you clear the flash. Then flash Tasmota. My Tasmota equipment is still normal.

Okay, which version of tasmota are you running on your devices?
Which version do you recommend to flash onto mine?

Which version should I choose from the flash tool?

Okay, which version of tasmota are you running on your devices?Which version do you recommend to flash onto mine?

I just erased and flashed the Sonoff again with tasmota firmware, but it's the same results. Failed to connect to MQTT. 
I tried an older firmware version and also the newest development build, but all without effect. Now I am back to the official 9.5 release version.

I was looking at th error codes now and it seems the that rc -2 from the console means that the clientID is rejected. 

Is there any chance that there is an issue on the IAMMETER cloud with the process of generating the clientID and then adding that client ID to the whitelist of allowed client IDs on the MQTT broker. Because it seems that the broker rejects my clientID. 

Also in the console it seems that it adds something (-3124) to the client ID at least when it shows the log of the webserver.

I don't know if that has any influence on the client ID it's sending to the MQTT broker.

After our test, it is found that Tasmota cannot clear the user name, which makes it impossible to only verify the ClientID when connecting to our mqtt server, so in order to continue to use Tasmota, set the ClientID and fill in the password of your iammeter mqtt account at the same time. And select the password item. At the same time in the test, I also encountered the problem that the Topic item only fills in the ClientID and cannot be saved, but we can use it through a workaround:

Client: your ClientID

User: your iammeter mqtt username

Password: your iammeter mqtt password(pls choose it)

Topic: device/your ClientID

Full Topic: %topic%/%prefix%/


Hi, okay great. Now it's working without problem.
So that is what I was seeing and reporting as well. It didn't work without username and password. And also the topic can't be only the client ID. But adding "device/" in front of it and removing "device/" from the full topic works as work around. 


Thank you very much for fixing this. 

At the first time when the mqtt feature had been supported , we check the clientid before username and password.
it mean if your clientid have been already verified, the username and password will be ignored.
I do not know why the tasmota firmware can not clear the username of mqtt to blank. (we had not found this problem before this post)

But our mqtt verification logic before seems work perfectly with the tasmota problem.

Last week, we upgrade our verification logic of mqtt, if username or password had been provided, they also must be valid. This upgrading cause the default username(when you clear the username in tasmota firmware, there is also a default username there) can not pass the vertification process. so you need to input both mqtt username and psassword in tasmota firmware now. Otherwise it will not pass the auth.
we will update our tasmota tutorial later(delete the description of keep username and password blank in tasmota)

Hi, okay great. Now it's working without problem.So that is what I was seeing and reporting as well. It didn't work without username and password. And also the topic can't be only the client ID. But adding "device/" in front of it and removing "device/" from the full topic works as work around. Thank you very much for fixing this. 

Hi,

I actually went back to the house again (with the wifi repeaters and OneMesh from TP-Link) and the MQTT connections fails again. 

In my apartment it was working without any issues after addressing the issue with the username and password. But here in the house it doesn't work still, even though having the same settings. As mentioned before, with a windows MQTT.fx tool I can connect from the house to your broker, so it doesn't seem to be blocked port or anything like this.

Can you check, whether you are getting the connections requests from my tasmota device and if there is any error in your logs, when trying to connect to your broker? Here are the identifiers:

Hi, 

we do not find your client in our mqtt broker now.

The log of the tasmota may be more useful than the pic you posted above.

You need to find out whether this problem is caused by the compatibility of the esp8266 or tasmota with your network device(router or repeater).
If so, we indeed can not provide any suggestions.
Please also note, the clientid can not be shared by two device. each client id will be corresponding to one unique socket. If two device share same client id, the second one will kick out the first one when it connected to the mqtt broker.

Hi,I actually went back to the house again (with the wifi repeaters and OneMesh from TP-Link) and the MQTT connections fails again. In my apartment it was working without any issues after addressing the issue with the username and password. But here in the house it doesn't work still, even though having the same settings. As mentioned before, with a windows MQTT.fx tool I can connect from the house to your broker, so it doesn't seem to be blocked port or anything like this.Can you check, wh

Hi, the log just shows that the MQTT failed to connect with return code (rc) 2:

I am not sharing the client ID with multiple devices. All the time I am using the same device to test. Just in my apartment it works without problem, but in the house it's having these issues all the time. 


1. You can use MQTT.fx to enter your clientID to see if you can connect 

2. Make sure your device can access the Internet

I can connect to the MQTT broker in that house network, using MQTT.fx from my laptop, which makes the whole thing very weird. From the laptop I can connect, but from the tasmota switch I cannot and get the error messages. 

Also the Tasmota switch has internet for sure, as it shows successful wifi connection in the log.

I can connect to the MQTT broker in that house network, using MQTT.fx from my laptop, which makes the whole thing very weird. From the laptop I can connect, but from the tasmota switch I cannot and get the error messages. 

Also the Tasmota switch has internet for sure, as it shows successful wifi connection in the log.

Hallo, I changed the router in the house and checked with the ISP, if any ports are blocked. They say that no ports are blocked, but I still have the issue, that the sonoff tasmota does not connect to the MQTT broker. 

10:13:15.229 MQT: Connect failed to mqtt.iammeter.com:1883, rc -2. Retry in 120 sec


Do you have maybe any new insights or are there any updates to your system or the tasmota system, that might fix any issues that might cause this?

Is it still only tasmota that works with your MQTT implementation or are there any other options that I could try that are compatible?

Thanks for your feedback.

We indeed think this problem is caused by the firmware of tasmota, but we are indeed not familiar with the code of tasmota.

Okay, I just tried something else and downgraded the tasmota firmware from 9.5 down to 8.5.1 and now it works without problems. So it seems that the latest release of tasmota firmware has some kind of bug or something that prevents it from connecting to the MQTT server.

Wow, this tread was helpfull !


I got the device, couldn't connect.

I thought: let's upgrade to the latest firmware !

Didn't connect.


Start searching, found this post, tried everything exactly the same, and only found this last post 2h later :-).


Downgraded to 8.5.1, and it works !!  Thanks !!


PS: Perhaps not a bad idea to mention it in the manual ?


BR

Wim

Thanks for your feedback.We indeed think this problem is caused by the firmware of tasmota, but we are indeed not familiar  with the code of tasmota.

Hi, thanks for your suggestion and please let me know which manual had you refer to before.
This feature looks like a "geek level" function which is a little difficult for normal customers.
So we have not introduced the corresponding content in most of our user manuals yet.

Wow, this tread was helpfull !I got the device, couldn't connect.I thought: let's upgrade to the latest firmware !Didn't connect.Start searching, found this post, tried everything exactly the same, and only found this last post 2h later :-).Downgraded to 8.5.1, and it works !!  Thanks !!PS: Perhaps not a bad idea to mention it in the manual ?BRWim

tnx a lot!

after about one week of trying to conect tasmota to mqtt brocker of imeter, after the downgrade of tasmota version to 8.5.0, now it work!

tanks again!

Okay, I just tried something else and downgraded the tasmota firmware from 9.5 down to 8.5.1 and now it works without problems. So it seems that the latest release of tasmota firmware has some kind of bug or something that prevents it from connecting to the MQTT server.

So appreciate for your remind

Try to increase the MQTT_CLIENT_WIFI_TIMEOUT either by compiling customer firmware or by using MqttWifiTimeout commandVersion 9.1.0.2 changed MQTT Wifi connection timeout from 5000ms to 200ms
Looks like you are new here. Register for free, learn and contribute.