tasmota public broker not working

1,428 views
Skip to first unread message

mohan RatiRam

unread,
Feb 3, 2022, 9:43:02 AM2/3/22
to TasmotaUsers
dear friends,

I installed the latest tasmota ( 10.1.0) and configured my MQTT broker as broker.hivemq.com, with port 1883 and no username and password. 

I might be overlooking something but I don't I understand why Tasmota is unable to reach the broker. I rolled back incrementally to previous versions of tasmota and realized version 9.1 and lower works correctly. Starting ver 9.2 and up until the current versions of the build has this connectivity issue. 

would appreciate if someone can suggest how to remedy the situation or recommend a workaround.

thanks in advance for your time and attention

best
mohan



mohan RatiRam

unread,
Feb 3, 2022, 9:48:07 AM2/3/22
to TasmotaUsers
just want to add one observation.....tasmota works well , if the broker is on a LAN. 192.168.0.166 and port 1883 for example.

ford.pre...@gmail.com

unread,
Feb 3, 2022, 10:25:27 AM2/3/22
to TasmotaUsers
...the easiest and - from the perspective of the device - most robust way to enable public presence is  to have it connected to a local broker and have the local broker connected via a mqtt bridge to the public broker.
That is the way I am using all of my tasmota devices, using mosquitto locally and cloudMQTT as public broker.

David Goadby

unread,
Feb 3, 2022, 7:35:09 PM2/3/22
to TasmotaUsers
I am using a number of 10.1.0 devices with MQTT and all works fine - well almost. The one thing I have not solved, but is a problem, is name resolution. I could not connect to any devices on my network by name, I had to use the IP address. I have been meaning to run Wireshark to check the traffic but direct IP addresses fixed it for now.

You could try using the ip address of broker.hivemq.com (35.157.158.119) directly for now. If you look at the information page on the device did you set the DNS Server 2 to something like 8.8.8.8 which is google's DNS? If DNS lookup is working in Tasmota then that should work.

I still cannot get the hostname to work correctly either. My routers'DHCP server issues an address ok  but I cannot set the hostname so I can look it up my my internal network.

Right now I am focussing on getting the system running but the DNS lookup is something I have to sort as fixed IP addresses is not the best way to go.

mohan RatiRam

unread,
Feb 4, 2022, 12:41:33 AM2/4/22
to TasmotaUsers
thank you for your response. In a way, I too have similar problem where I could not connect to any devices on my network by name, I had to use the IP address. 

Using ip address  instead of broker.hivemq.com did not solve the issue. I tried other public brokers but had the same issue. Surprisingly, I am able to connect to all the public brokers using mqtt explorer and mqtt box. 


here are the details of the information page 

Sonoff Basic Module
Tasmota
Program Version        9.2.0(tasmota)
Build Date & Time        2020-12-21T15:03:40
Core/SDK Version        2_7_4_9/2.2.2-dev(38a443e)
Uptime        0T00:08:40
Flash write Count        21 at 0xF7000
Boot Count        10
Restart Reason        Software/System restart
Friendly Name 1        Tasmota
 
AP1 SSId (RSSI)        home_network (100%, -50 dBm)
Hostname        tasmota_2E999E-6558
MAC Address        C8:2B:96:2E:99:9E
IP Address (wifi)        192.168.1.14
Gateway        192.168.1.1
Subnet Mask        255.255.255.0
DNS Server        192.168.1.1
 
MQTT Host        mqtt.eclipse.org
MQTT Port        1883
MQTT User        DVES_USER
MQTT Client        DVES_2E999E
MQTT Topic        tasmota_%06X
MQTT Group Topic 1        cmnd/tasmotas/
MQTT Full Topic        cmnd/tasmota_2E999E/
MQTT Fallback Topic        cmnd/DVES_2E999E_fb/
MQTT No Retain        Disabled
 
Emulation        None
mDNS Discovery        Disabled
 
ESP Chip Id        3053982
Flash Chip Id        0x1740EF
Flash Size        8192kB
Program Flash Size        8192kB
Program Size        586kB
Free Program Space        416kB
Free Memory        26kB


thanks in advance for your time and attention!

cheers
mohan

Philip Knowles

unread,
Feb 4, 2022, 1:14:59 AM2/4/22
to mohan RatiRam, TasmotaUsers
This may be a DNS issue in your router. The console log is more helpful than the info page because you would be able to see the MQTT result code


From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of mohan RatiRam <moha...@gmail.com>
Sent: Friday, February 4, 2022 5:41:33 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: tasmota public broker not working
 
--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/6a176bfa-43f7-407d-95e2-2c2060ff172cn%40googlegroups.com.

mohan RatiRam

unread,
Feb 4, 2022, 1:41:58 AM2/4/22
to TasmotaUsers
initially I too suspected the DNS issue in my router but I am wondering why I should mess with it when 

1. IP address , instead of broker.hivemq.com is also failing
2. tasmota ver 9.1 and lower , the MQTT Explorer and MQTT are humming along well with broker.hivemq.com or any other public broker
 


at any rate, here is console output...

00:00:00.049 CFG: Loaded from flash at F4, Count 8
00:00:00.055 QPC: Count 1
00:00:00.061 Project tasmota Tasmota Version 9.2.0.6(tasmota)-2_7_4_9(2021-02-06T17:20:11)
00:00:00.549 WIF: Connecting to AP1 home_network Channel 6 BSSId 4C:60:DE:42:8A:ED in mode 11n as tasmota_2E999E-6558...
00:00:03.755 WIF: Connected
00:00:04.006 HTP: Web server active on tasmota_2E999E-6558 with IP address 192.168.1.14
12:07:18.006 MQT: Attempting connection...
12:07:18.222 MQT: Connect failed to broker.hivemq.com:1883, rc -2. Retry in 10 sec
12:07:19.427 QPC: Reset
12:07:29.029 MQT: Attempting connection...
12:07:29.242 MQT: Connect failed to broker.hivemq.com:1883, rc -2. Retry in 20 sec

any help is resolving this is greatly appreciated!

best

Philip Knowles

unread,
Feb 4, 2022, 2:38:40 AM2/4/22
to mohan RatiRam, TasmotaUsers
So result code 2 is a rejection from the broker so Tasmota has connected but the connection has been refused. That may be caused by needing some further configuration 
Sent: Friday, February 4, 2022 6:41:58 AM

Philip Knowles

unread,
Feb 4, 2022, 3:02:47 AM2/4/22
to mohan RatiRam, TasmotaUsers
BTW. I don't use a public broker but you should think about how you are going to easily retrieve the information. I would consider having part of the topic unique to yourself, say, mohan/tasmota_06%X so that all of your MQTT traffic is in one subset.

Also BTW rc 2 is normally caused by an issue with the device name so prefixing the device names with mohan may help.
Have you opened the webhooks port on your router too?

Regards

Phil K
From: Philip Knowles <knowles...@gmail.com>
Sent: Friday, February 4, 2022 7:38:33 AM
To: mohan RatiRam <moha...@gmail.com>; TasmotaUsers <sonof...@googlegroups.com>

mohan RatiRam

unread,
Feb 4, 2022, 4:02:35 AM2/4/22
to TasmotaUsers
Other than username and password, I don't see any option in tasmota menu I can specify as connect parameter. 

I tried playing with these commands on console without much luck ..
Backlog mqtthost broker.hivemq.com; mqttport 1883; mqttuser mohan; mqttpassword mohan; topic mytopic

The only thing different in connecting via the MQTT box is that we have to specify the client name in the tool.  could that cause the problem ? If so, is there a way to specify the client name in Tasmota MQTT connect packet?

regards
mohan

mohan RatiRam

unread,
Feb 4, 2022, 4:09:47 AM2/4/22
to TasmotaUsers

 public broker is only for the initial POC phase. Eventually we will be hosting the broker on our servers. 

I tried prefixing device name in "configuring other" menu without much luck :( and I don't see any open ports in my Netgear N150 router. 

best,
mohan

Philip Knowles

unread,
Feb 4, 2022, 4:38:56 AM2/4/22
to mohan RatiRam, TasmotaUsers

OK so I configured a device using broker.hivemq.com

Here is my log

00:00:02.023 HTP: Web server active on Sonoff-Pump with IP address 192.168.2.120

09:30:55.025 MQT: Attempting connection...

09:30:55.185 MQT: Connected

This is on v10.1.0 and it connected without issue. Are the Client and the Topic different? Tasmota does not allow them to be the same–  for the above device the Client is Pump-Sonoff and the Topic Sonoff-Pump . Hivemq uses Websocket Port 8000 so your router will need to allow that port to be used

 

Regards

 

Phil K

 

Sent from Mail for Windows

 

From: mohan RatiRam
Sent: 04 February 2022 09:02
To: TasmotaUsers
Subject: Re: tasmota public broker not working

 

Other than username and password, I don't see any option in tasmota menu I can specify as connect parameter. 

 

I tried playing with these commands on console without much luck ..

Backlog mqtthost broker.hivemq.com; mqttport 1883; mqttuser mohan; mqttpassword mohan; topic mytopic

The only thing different in connecting via the MQTT box is that we have to specify the client name in the tool.  could that cause the problem ? If so, is there a way to specify the client name in Tasmota MQTT connect packet?

 

regards

mohan

 

On Friday, 4 February 2022 at 13:08:40 UTC+5:30 knowles...@gmail.com wrote:

So result code 2 is a rejection from the broker so Tasmota has connected but the connection has been refused. That may be caused by needing some further configuration 

mohan RatiRam

unread,
Feb 4, 2022, 7:21:31 AM2/4/22
to TasmotaUsers

for testing purposes, I set my Client as Pump-Sonoff and the Topic as Sonoff-Pump and  get the same error , this time using test.mosquitto.org. I chose a different broker on purpose just to eliminate it is not a broker.hivemq.com problem in specific but a public broker in general. 


here is the log..

00:00:04.004 HTP: Web server active on mohan with IP address 192.168.1.8
17:45:08.005 MQT: Attempting connection...
17:45:08.415 MQT: Connect failed to test.mosquitto.org:1883, rc -2. Retry in 10 sec
17:45:09.415 QPC: Reset
17:45:19.009 MQT: Attempting connection...
17:45:19.224 MQT: Connect failed to test.mosquitto.org:1883, rc -2. Retry in 20 sec
17:45:40.008 MQT: Attempting connection...
17:45:40.228 MQT: Connect failed to test.mosquitto.org:1883, rc -2. Retry in 30 sec
17:46:11.050 MQT: Attempting connection...
17:46:11.261 MQT: Connect failed to test.mosquitto.org:1883, rc -2. Retry in 40 sec

I hope this helps!

I appreciate your time and effort in helping with this issue.

mohan RatiRam

unread,
Feb 4, 2022, 7:36:03 AM2/4/22
to TasmotaUsers
just to reiterate, everything works well on Tasmota 9.1 and below

trouble begins with 9.2 and above 

mohan

unread,
Feb 12, 2022, 9:14:45 AM2/12/22
to Peter Diffey, TasmotaUsers
Thank you for your reply. As mentioned earlier, i am to successfully connect to the public brokers using the MQTT client(s). 

I can also connect using tasmota 9.1 and lower.

Warm regards
mohan 

On Sat, Feb 12, 2022, 7:12 PM Peter Diffey <pe...@heroic.co.uk> wrote:
Have you checked that you can actually reach the broker?

Try using telnet command from a Linux box eg

telnet broker.hivemq.com 1883

You should get an answer like

Connecting to broker...
Escape character is xxx

If you don't get any answer, then the port on broker is not open

If it does work then you have a local issue.

Pedro
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

Mark Desk

unread,
Feb 24, 2022, 8:34:21 PM2/24/22
to TasmotaUsers
Hello,

I am having exactly the same problem as Mohan. Old Tasmota versions(<= 9.1) work, but newer version don't!
I trying the version 11, but same problems. Always with error code 2.  Tried with test.mosquitto.org and also with my own mqtt server running on VPN. 
Does anyone have a similar issue? Any suggestions?
Thanks.

Philip Knowles

unread,
Feb 25, 2022, 1:51:54 PM2/25/22
to Mark Desk, TasmotaUsers

Can you share the config page for MQTT. I tried a test with v10.1 and v11 and successfully connected to the hive broker. Most rc -2 issues are caused by network issues not Tasmota.

 

Regards

 

Phil K

 

Sent from Mail for Windows

 

From: Mark Desk
Sent: 25 February 2022 01:34
To: TasmotaUsers
Subject: Re: tasmota public broker not working

 

Hello,

--

You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.

mohan

unread,
Feb 25, 2022, 6:54:45 PM2/25/22
to Philip Knowles, Mark Desk, TasmotaUsers
don't mean to jump in out of turn but here's my MQTT config page.

I get an rc2 in console...


00:00:03.753 WIF: Connected
00:00:04.005 HTP: Web server active on overhead-tank with IP address 192.168.1.5
05:17:14.041 MQT: Attempting connection...
05:17:14.260 MQT: Connect failed to broker.hivemq.com:1883, rc -2. Retry in 10 sec
05:17:25.034 MQT: Attempting connection...
05:17:25.249 MQT: Connect failed to broker.hivemq.com:1883, rc -2. Retry in 20 sec
05:17:46.044 MQT: Attempting connection...
05:17:46.261 MQT: Connect failed to broker.hivemq.com:1883, rc -2. Retry in 30 sec
05:18:17.013 MQT: Attempting connection...
05:18:17.239 MQT: Connect failed to broker.hivemq.com:1883, rc -2. Retry in 40 sec
05:18:58.023 MQT: Attempting connection...
05:18:58.243 MQT: Connect failed to broker.hivemq.com:1883, rc -2. Retry in 50 sec
05:19:49.274 MQT: Attempting connection...
05:19:49.503 MQT: Connect failed to broker.hivemq.com:1883, rc -2. Retry in 60 sec
05:20:50.299 MQT: Attempting connection...
05:20:50.718 MQT: Connect failed to broker.hivemq.com:1883, rc -2. Retry in 70 sec




Regards
mohan




You received this message because you are subscribed to a topic in the Google Groups "TasmotaUsers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonoffusers/6OnfvhO6u8o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/7BC11114-F11F-4557-BB8C-B20876FDDF14%40hxcore.ol.
Screenshot_20220226-051741.jpg

Mark Desk

unread,
Feb 25, 2022, 7:47:30 PM2/25/22
to TasmotaUsers
Thanks both of you for replying. I just put the test.mosquitto.org on the host field in the MQTT settings, I left everything else as default. If I use  Old Tasmota versions(<= 9.1)  it works. If I use newer versions it does not connect, exactly as mohan posted.

mohan RatiRam

unread,
Feb 25, 2022, 10:55:57 PM2/25/22
to TasmotaUsers
 there is a high probability Phil has trained Tasmota to  faithfully  take orders and never deny any service  :) 

Phil, if you could share the secret sauce please :)

best,
mohan

Philip Knowles

unread,
Feb 26, 2022, 12:45:33 AM2/26/22
to mohan RatiRam, TasmotaUsers
I suspect that you have a DNS issue.
All I changed was the address of the MQTT broker and it connected straight away. 
Sent: Saturday, February 26, 2022 3:55:57 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Screenshot_20220226-053916.png
Screenshot_20220226-053933.png

mohan

unread,
Feb 26, 2022, 4:59:51 AM2/26/22
to Philip Knowles, TasmotaUsers
if DNS was not playing well...
1. Tasmota should have connected using the IP address
2. MQTT explorer would have failed but it works well as shown in the screenshot.

image.png

I tried connecting Tasmota to a public broker from my office as well as my home without much luck. 

best,
mohan 



Philip Knowles

unread,
Feb 26, 2022, 11:59:08 AM2/26/22
to mohan, TasmotaUsers

Perhaps but I can connect to hive using v10.1 – that points to an issue in your setup not in Tasmota. The version I use on that device is a pre-compiled sensors.bin. That device has been in use since v5.12

 

I would erase and re-flash to see if something is corrupted in flash – bear in mind too that downgrading below v9.1 is not supported by Tasmota anyway. Migration has to go via v9.1 and if that was skipped that may cause an issue too.

 

Regards

 

Phil K

 

 

 

Sent from Mail for Windows

 

From: mohan
Sent: 26 February 2022 09:59
To: Philip Knowles
Cc: TasmotaUsers
Subject: Re: tasmota public broker not working

 

if DNS was not playing well...

1. Tasmota should have connected using the IP address

2. MQTT explorer would have failed but it works well as shown in the screenshot.

 

 

I tried connecting Tasmota to a public broker from my office as well as my home without much luck. 

 

best,

mohan 

 

 

 

On Sat, Feb 26, 2022, 11:15 AM Philip Knowles <knowles...@gmail.com> wrote:

I suspect that you have a DNS issue.

All I changed was the address of the MQTT broker and it connected straight away. 

Mark Desk

unread,
Feb 26, 2022, 1:00:55 PM2/26/22
to TasmotaUsers
Hello again,
As for me the newest version which works with MQTT is the 9.1, I will post the tests with 9.1 and with 11.0(as it is, at the time of this post, the latest one).
I made some tests here(all tests are made erasing the entire flash with Tasmotizer, flashing the firmware tasmota.bin and only changing the MQTT host):
With firmware 9.1:
It can connect to test.mosquitto.org
With firmware 11.0:
It cannot connect to test.mosquitto.org with ec - 2

Testing it further, I installed a broker on my own VPS and set an user and password.
With firmware 9.1:
It can connect to my broker installed on my VPS using user and password.
With firmware 11.0:
It cannot connect to my broker installed on my VPS using user and password and returns ec - 2

So I decided to change my DNS from OpenDNS to Google DNS and the problem continues with firmware 11.0

Something changed after firmware 9.1 that brakes the connection, but it seems it is not for everyone as Phil can still connect. 
Phil, are you using the generic tasmota firmware (tasmota.bin)?

Mark Desk

unread,
Feb 26, 2022, 2:51:11 PM2/26/22
to TasmotaUsers
Hello once more!!

I just found the problem and fixed it! The problem is the timeout setting on the firmware. I changed it and recompiled and problem solved!
Mohan, I attached the firmware I compiled, so you can test. Please let me know if it works for you too.
tasmota_11.0_MQTT_timeout_fixed.bin

mohan

unread,
Feb 26, 2022, 6:54:08 PM2/26/22
to Mark Desk, TasmotaUsers
That's good news Mark 👍

I will try your firmware and update you later today. In the meantime , could you please tell me the name of the file, the  setting and it's new value that solved the problem. 

Thank you very much
mohan 

I

mohan

unread,
Feb 26, 2022, 10:47:18 PM2/26/22
to Mark Desk, TasmotaUsers
Hi Mark,
Thank you for resolving the issue, your build works well. 
I bumped up the MQTT_WIFI_CLIENT_TIMEOUT from it's default 200ms to 2000ms (2 secs) and was able to compile a working firmware. 

btw, these (possibly several others) attributes were added post 9.1.  

#define MQTT_KEEPALIVE         30                // [MqttKeepAlive] Number of seconds between KeepAlive messages
#define MQTT_SOCKET_TIMEOUT    4                //  [MqttTimeout] Number of seconds before Mqtt connection timeout
#define MQTT_WIFI_CLIENT_TIMEOUT 200             //  [MqttWifiTimeout] Number of milliseconds before Mqtt Wi-Fi timeout

Version 9.1.0.2 changed MQTT Wifi connection timeout from 5000ms to 200ms (#9886). 

Phil is not experiencing this because he probably has a faster router and/or internet connection . 

It's a happy world again :) 

best,
mohan

 


Mark Desk

unread,
Feb 27, 2022, 12:29:18 AM2/27/22
to TasmotaUsers
Hi Mohan,
Great news!! After I compiled the firmware I noticed you can also change the MQTT WIFI timeout with this command in the console:
MqttWifiTimeout
So no need to compile if this is the only problem. But I need to compile anyway as I am using TLS.

Regards,

Mark

mohan

unread,
Feb 27, 2022, 1:07:59 AM2/27/22
to Mark Desk, TasmotaUsers
Thank you for MQTT WIFI command tip. 

You can also play with MQTT socket time out using the MQTTTimeout command.

best regards
mohan 

Rob Clark

unread,
Feb 28, 2022, 7:36:23 AM2/28/22
to sonof...@googlegroups.com
Normally it does not make sense to use the Tasmota WiFi interface as an AP - except for the initial setup phase.

But I have been using this ESP32 based board with Tasmota loaded.
https://templates.blakadder.com/lilygo_T-Internet-POE.html

Because it has a wired LAN interface, using the WiFi in client (station) mode is redundant. But the WiFi could be used in AP mode.
(No routing function needed. Just bridging of the LAN & WiFi interfaces.)

I am looking for advice on how to setup the WiFi in AP mode but I am not sure where to start.

WHY?
  1. Learning exercise
  2. May have applications at remote (solar?) sites where a small, PoE powered, short-range AP is useful.

CONS?

  1. Slow
  2. Short range
  3. Need to modify the code and recompile. (Not a problem for me). Bridging the interfaces may be a lot of new code?

PROS?

  1. If a small PoE AP is needed, may be an elegant solution.

Any advice welcome.


Kim Wall

unread,
Feb 28, 2022, 8:02:42 AM2/28/22
to TasmotaUsers
Not Tasmota, but
<https://github.com/espressif/esp-iot-solution/tree/release/v1.1/examples/eth2wifi>
is probably a good starting point.


Kim.

On 28/02/2022 12:36, Rob Clark wrote:
> Normally it does not make sense to use the Tasmota WiFi interface as an
> AP - except for the initial setup phase.
>
> But I have been using this ESP32 based board with Tasmota loaded.
> https://templates.blakadder.com/lilygo_T-Internet-POE.html
>
> Because it has a wired LAN interface, using the WiFi in client (station)
> mode is redundant. But the WiFi could be used in AP mode.
> (No routing function needed. Just bridging of the LAN & WiFi interfaces.)
>
> I am looking for advice on how to setup the WiFi in AP mode but I am not
> sure where to start.
>
> WHY?
>
> 1. Learning exercise
> 2. May have applications at remote (solar?) sites where a small, PoE
> powered, short-range AP is useful.
>
> CONS?
>
> 1. Slow
> 2. Short range
> 3. Need to modify the code and recompile. (Not a problem for me).
> Bridging the interfaces may be a lot of new code?
>
> PROS?
>
> 1. If a small PoE AP is needed, may be an elegant solution.
>
> Any advice welcome.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "TasmotaUsers" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sonoffusers...@googlegroups.com
> <mailto:sonoffusers...@googlegroups.com>.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/sonoffusers/2afcdc85-5454-7c8e-2339-38daebe35106%40gmail.com
> <https://groups.google.com/d/msgid/sonoffusers/2afcdc85-5454-7c8e-2339-38daebe35106%40gmail.com?utm_medium=email&utm_source=footer>.
kim.vcf
OpenPGP_signature
Reply all
Reply to author
Forward
0 new messages