MQTT : Failed to connected to broker

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
darek
Normal user
Posts: 11
Joined: 07 Jan 2016, 12:31

MQTT : Failed to connected to broker

#1 Post by darek » 12 Feb 2016, 22:42

After changed protocol to mqtt domoticz I noticed that all my nodemcu (v2 i v3) have some problem with broker (mosquitto) connection.
From time to time (1 hour) I see something as:

1455311799: Client ESPClient1 has exceeded timeout, disconnecting.
1455311799: Socket error on client ESPClient1, disconnecting.

or

1455311700: New client connected from 192.168.10.118 as ESPClient2 (c1, k15, u'b2').
1455311715: Socket error on client ESPClient2, disconnecting.


Further investigation showed some problem with esp wifi:


{"idx":8,"nvalue":0,"svalue":"29.46;0;0;999.07;0"}
bcn_timout,ap_probe_send_start
ap_probe_send over, rest wifi status to disassoc
state: 5 -> 0 (1)
rm 0
pm close 7
f r-40, MQTT : Failed to connected to broker
MQTT : Failed to connected to broker
WD : Uptime 109 ConnectFailures 4 FreeMem 29048
MQTT : Connection lost
MQTT : Failed to connected to broker
scandone
no Qlin found, reconnect after 1s
reconnect
f 0, MQTT : Failed to connected to broker
10 ps:336 uS 1 ps:164 uS
10 ps:249 uS 1 ps:220 uS
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 1
cnt

connected with Qlin, channel 1
dhcp client start...
chg_B1:-40


Other mqtt clients working to this broker without problems.
I tested esp easy R60 - R78

Any help is greatly appreciated(;

MarkIngle
Normal user
Posts: 47
Joined: 10 Feb 2016, 05:06

Re: MQTT : Failed to connected to broker

#2 Post by MarkIngle » 13 Feb 2016, 05:39

I am having the same problem. Rel 78 using mossquito broker. I am at a loss as to what the problem is and how to troubleshoot

INIT : Booting Build nr:78
WIFI : Connecting... 1
WIFI : Connected!
INIT : I2C
MQTT : Failed to connected to broker
MQTT : Failed to connected to broker
INIT : Boot OK
INIT : Normal boot
WD : Uptime 0 ConnectFailures 0 FreeMem 26424
MQTT : Connection lost
MQTT : Failed to connected to broker
MQTT : Failed to connected to broker
WD : Uptime 1 ConnectFailures 2 FreeMem 26336
MQTT : Connection lost
MQTT : Failed to connected to broker

highroller
Normal user
Posts: 31
Joined: 09 Feb 2016, 22:16

Re: MQTT : Failed to connected to broker

#3 Post by highroller » 13 Feb 2016, 13:33

MarkIngle wrote:I am having the same problem. Rel 78 using mossquito broker. I am at a loss as to what the problem is and how to troubleshoot

INIT : Booting Build nr:78
WIFI : Connecting... 1
WIFI : Connected!
INIT : I2C
MQTT : Failed to connected to broker
MQTT : Failed to connected to broker
INIT : Boot OK
INIT : Normal boot
WD : Uptime 0 ConnectFailures 0 FreeMem 26424
MQTT : Connection lost
MQTT : Failed to connected to broker
MQTT : Failed to connected to broker
WD : Uptime 1 ConnectFailures 2 FreeMem 26336
MQTT : Connection lost
MQTT : Failed to connected to broker
Do the mosquitto logs say anything about the connectionattempts?

MarkIngle
Normal user
Posts: 47
Joined: 10 Feb 2016, 05:06

Re: MQTT : Failed to connected to broker

#4 Post by MarkIngle » 13 Feb 2016, 15:40

That's a problem too. I cannot figure out where the logs are located or even if logging is enabled. I'm running the broker on Windows 7

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: MQTT : Failed to connected to broker

#5 Post by tozett » 13 Feb 2016, 22:16

windows firewall blocking?
may disable the windows firewall in the services for testing?

MarkIngle
Normal user
Posts: 47
Joined: 10 Feb 2016, 05:06

Re: MQTT : Failed to connected to broker

#6 Post by MarkIngle » 13 Feb 2016, 22:40

I finally figured out how to get the mosquitto log files created. At this point I am only get a service startup message.

My lab in environment is really simple I have the broker service running on my laptop. The laptop and ESP are on the same wifi network and I can ping the ESP.

I will do more testing and post results here.

Mark

highroller
Normal user
Posts: 31
Joined: 09 Feb 2016, 22:16

Re: MQTT : Failed to connected to broker

#7 Post by highroller » 13 Feb 2016, 22:56

Here are some guides on how to eneable logging in windows.

https://www.google.no/search?q=mosquitt ... ndows+logs

MarkIngle
Normal user
Posts: 47
Joined: 10 Feb 2016, 05:06

Re: MQTT : Failed to connected to broker

#8 Post by MarkIngle » 13 Feb 2016, 23:40

I have logging tuned on but nothing is being posted to the log file. I also have the ESP DEbug level set to 4.

Here is the log info from the ESP....hopefully someone will see something. At this point I dont whatelse to check

ets Jan 8 2013,rst cause:2, boot mode:(3,7)

load 0x4010f000, len 1264, room 16
tail 0
chksum 0x42
csum 0x42
~ld
ªU
INIT : Booting Build nr:78
bcn 0
del if1
usl
sul 0 0
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100
bcn 0
del if1
usl
sul 0 0
mode : sta(5c:cf:7f:06:25:4f)
add if0
WIFI : Connecting... 1
f 0, scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 3
pm open phy_2,type:2 0 0
cnt

connected with TheIngles_APE, channel 11
dhcp client start...
ip:10.0.1.37,mask:255.255.255.0,gw:10.0.1.1
WIFI : Connected!
INIT : I2C
MQTT : Failed to connected to broker
MQTT : Failed to connected to broker
INIT : Boot OK
INIT : Normal boot

MarkIngle
Normal user
Posts: 47
Joined: 10 Feb 2016, 05:06

Re: MQTT : Failed to connected to broker

#9 Post by MarkIngle » 14 Feb 2016, 06:01

After working through my firewall issues I was able to get some logging. I decided to move my troubleshooting to my Mac mini and it paid in getting more information. Below is a log file showing a successful connection between a mosquito_sub client(10.0.1.6) connected to the mosquito broker service on the Mac Mini.

1455424480: Socket read error on client mosqsub/5332-Multirotor, disconnecting.
1455424576: Client mosqsub/65242-Mac-mini. has exceeded timeout, disconnecting.
1455425246: New connection from 10.0.1.6.
1455425246: New client connected from 10.0.1.6 as mosqsub/1032-Multirotor.
1455425384: New connection from 10.0.1.2.
1455425384: Invalid protocol "MQTT" in CONNECT from 10.0.1.2.
1455425384: Socket read error on client (null), disconnecting.
1455425399: New connection from 10.0.1.2.
1455425399: Invalid protocol "MQTT" in CONNECT from 10.0.1.2.
1455425399: Socket read error on client (null), disconnecting.
1455425416: New connection from 10.0.1.2.
1455425416: Invalid protocol "MQTT" in CONNECT from 10.0.1.2.

Below you see the "invalid protocol..." coming from the ESP device (10.0.1.2). This error msg keeps repeating so the firmware on the ESP keeps trying.

Any ideas where I should be looking to correct this?
Why would MQTT be the wrong protocol?
#confusedonthisone!!!

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: MQTT : Failed to connected to broker

#10 Post by tozett » 14 Feb 2016, 10:14

can only give a guess:
maybe the ususal linux MOSQUITO-MQTT implementation as Broker for the ESP-clients is _not_
identical with your mac-MQTT implementation?

something for the devs to dig in? do you have more details of your mac MQTT software?

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: MQTT : Failed to connected to broker

#11 Post by tozett » 14 Feb 2016, 14:38

just actually stumbled upon this:
Note that for now PubSubClient requires a broker that supports version 3.1.1 of the MQTT standard, not 3.1 or earler.
For Mosquitto, this means version 1.3 or later. Although version 1.3 only officially supports MQTT 3.1, it does accept the "MQTT" protocol name string in the CONNECT message (MQTT 3.1 uses "MQIsdp"). Version 1.4 is recommended however, as it fully supports MQTT 3.1.1.
https://github.com/Imroy/pubsubclient

which it think is in ESPeasy. may you check this version requirements with your broker on the mac?

MarkIngle
Normal user
Posts: 47
Joined: 10 Feb 2016, 05:06

Re: MQTT : Failed to connected to broker

#12 Post by MarkIngle » 14 Feb 2016, 19:19

I found this post that explains what is going on. Not sure I completely understand how to resolve the MQTT 3.1/3.1.1 version issue. So its a compatibility problem between Rev 78 and Mosquitto 1.4.7 which is using MQTT 3.1...at least this is how I understand it. Someone please correct me if this is incorrect.

I found this post which explains the issue.

http://jasecunningham.co.uk/index.php/2 ... n-connect/

I pointed my ESP to test.mosquitto.org:1883. The ESP client and the hosted broker connected. My next step will be to turn off the LED via openHAB.

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: MQTT : Failed to connected to broker

#13 Post by tozett » 14 Feb 2016, 19:52

MarkIngle wrote: The ESP client and the hosted broker connected.
maybe you rename this thread hereby to SOLVED?
;)

MarkIngle
Normal user
Posts: 47
Joined: 10 Feb 2016, 05:06

Re: MQTT : Failed to connected to broker

#14 Post by MarkIngle » 14 Feb 2016, 20:00

I dont mind changing the topic to SOLVED once I get the LED working. But what about the issue of compatibility with MQTT? How should that be tracked? Or is it just not worth it?

MarkIngle
Normal user
Posts: 47
Joined: 10 Feb 2016, 05:06

[SOLVED] MQTT : Failed to connected to broker

#15 Post by MarkIngle » 14 Feb 2016, 21:00

darek wrote:After changed protocol to mqtt domoticz I noticed that all my nodemcu (v2 i v3) have some problem with broker (mosquitto) connection.
From time to time (1 hour) I see something as:

1455311799: Client ESPClient1 has exceeded timeout, disconnecting.
1455311799: Socket error on client ESPClient1, disconnecting.

or

1455311700: New client connected from 192.168.10.118 as ESPClient2 (c1, k15, u'b2').
1455311715: Socket error on client ESPClient2, disconnecting.


Further investigation showed some problem with esp wifi:


{"idx":8,"nvalue":0,"svalue":"29.46;0;0;999.07;0"}
bcn_timout,ap_probe_send_start
ap_probe_send over, rest wifi status to disassoc
state: 5 -> 0 (1)
rm 0
pm close 7
f r-40, MQTT : Failed to connected to broker
MQTT : Failed to connected to broker
WD : Uptime 109 ConnectFailures 4 FreeMem 29048
MQTT : Connection lost
MQTT : Failed to connected to broker
scandone
no Qlin found, reconnect after 1s
reconnect
f 0, MQTT : Failed to connected to broker
10 ps:336 uS 1 ps:164 uS
10 ps:249 uS 1 ps:220 uS
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 1
cnt

connected with Qlin, channel 1
dhcp client start...
chg_B1:-40


Other mqtt clients working to this broker without problems.
I tested esp easy R60 - R78

Any help is greatly appreciated(;

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: MQTT : Failed to connected to broker

#16 Post by tozett » 15 Feb 2016, 07:48

i am not very experienced with MQTT,
but your link showed up, that the (mosquito) broker should be updated to protocol ver 3.1.1.
what broker do you use on the mac? you mentioned it?

maybe first to google how to check MQTT protocol versions of the broker?

i quoted above from the pubsubclient github-readme, that they suggest to use Mosquitto 1.4 or up.
http://www.esp8266.nu/forum/viewtopic.p ... 4213#p4168
do you have this? cant see from your post...

another observation yesterday, as i thied to compile a new pubsubclient in arduino ide for a led-ws2812-experiment i noticed,
that the source was updated from 1.9.1 to 1.99.1 on github.
i compiled my R078 with old 1.9.1 source. dont know which one you used to build the ESPeasy firmware..
maybe you want to check this also?

dont know which one was used by the devs to build the R078 procompiled binary package, what is downloadable here:
http://www.esp8266.nu/downloads/ESPEasy_R78.zip
dont know how to check wich MQTT procol version is in this compiled binary,

but it looks like that one has to check deeper the procol version of MQTT client and broker for your problem..
may the devs have some more hints...
:|

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: MQTT : Failed to connected to broker

#17 Post by tozett » 15 Feb 2016, 09:41

i searched the forum and found this discussion about protocol 3.1.1 and
mosquito update.
may this helps?
http://www.esp8266.nu/forum/viewtopic.p ... 4121#p1098

darek
Normal user
Posts: 11
Joined: 07 Jan 2016, 12:31

Re: MQTT : Failed to connected to broker

#18 Post by darek » 15 Feb 2016, 11:24

Thanks tozeet for try to help me.

Code: Select all

dpkg -l  mosquitto
||/ Name                Version        Architecture   Description
+++-===================-==============-==============-===========================================
ii  mosquitto           1.4.7-0mosquit armhf          MQTT version 3.1/3.1.1 compatible message
and seems to be correct. I don't see any "invalid protocol " as MarkIngle. Also I have installed mosquitto from http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key

I have R78-develop with pubsubclient ver 1.9 (change.log). On github I found v2.6 but this I can't compile to esp project

Code: Select all

no matching function for call to 'PubSubClient::PubSubClient(const char [1])
Also for some test I connected to public mqtt server iot.eclipse.org but I meet the same problem.

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: [SOLVED] MQTT : Failed to connected to broker

#19 Post by tozett » 15 Feb 2016, 11:54

MarkIngle wrote:
darek wrote: bcn_timout,ap_probe_send_start
ap_probe_send over, rest wifi status to disassoc
state: 5 -> 0 (1)
rm 0
pm close 7
f r-40, MQTT : Failed to connected to broker
i bound my esp12 R078 (pubsub 1.9, i guess) to my raspberry with mosquitto 1.4.5 without any prob.
i checked with mosquito.fx (for fun). seems to work. i looked into your post, but:

maybe you have a wifi-problem _before_ the MQTT problem?
may you check your wifi setup? may the ESP stops the wifi connection?
maybe change your AP, or Position, or Wifi strength?

if the wifi is lost, than the MQTT cant send... :roll:

MarkIngle
Normal user
Posts: 47
Joined: 10 Feb 2016, 05:06

Re: MQTT : Failed to connected to broker

#20 Post by MarkIngle » 15 Feb 2016, 14:47

My Mac was running Mosquitto as the broker and it is using MQTT 3.1

It was installed using Homebrew. I tried to figure out how to get a more recent version of mosquitto installed but was not able to do so.

Until then I am using test.mosguitto.org as a broker and I have the LED working (ON/OFF) via openHAB.

My next project is to get a HC-SR04 working and also integrate it into openHAB. (fingers crossed!)

I plan on using another broker service...there are several to choose from.

Thanks for the help guys! I really appreciate it very much!

Mark

darek
Normal user
Posts: 11
Joined: 07 Jan 2016, 12:31

Re: MQTT : Failed to connected to broker

#21 Post by darek » 16 Feb 2016, 11:47

I have considered wifi-problem and I'm testing network (ping test). At this moment I don't see any problems with network.
Also I used few ESPs in two localizations in two AP.

Is there any way to switch off a subscription from esp mqtt?

wutu
Normal user
Posts: 35
Joined: 05 Feb 2016, 07:33

Re: MQTT : Failed to connected to broker

#22 Post by wutu » 05 Jun 2016, 10:09

I have the version R91, R100, R103 and 2x R107. When I retart the AP, only R91 to connect always. Other versions someone joins permanently or end up in a loop (Socket error on client ESPClientX, disconnecting.).
I'm using OpenHAB MQTT, Broker Mosquitto 1.4.9 on Linux.

sozkara
Normal user
Posts: 14
Joined: 02 Jun 2016, 09:07

Re: MQTT : Failed to connected to broker

#23 Post by sozkara » 25 Jun 2016, 12:04

I too have problems with MQTT with rev 108 on two different devices. Here's my sample log :
Log
299837625 : MQTT : Connected to broker
299837629 : Subscribed to: /oturma grubu/#
299866607 : WD : Uptime 4997 ConnectFailures 17774 FreeMem 27880
299866607 : MQTT : Connection lost
299867624 : MQTT : Connected to broker
299867629 : Subscribed to: /oturma grubu/#
299896608 : WD : Uptime 4998 ConnectFailures 17776 FreeMem 27880
299896608 : MQTT : Connection lost
299897631 : MQTT : Connected to broker
299897634 : Subscribed to: /oturma grubu/#

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: MQTT : Failed to connected to broker

#24 Post by JR01 » 25 Jun 2016, 12:19

And if you remove the space in /oturma grubu/ ?
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

sozkara
Normal user
Posts: 14
Joined: 02 Jun 2016, 09:07

Re: MQTT : Failed to connected to broker

#25 Post by sozkara » 25 Jun 2016, 13:35

Nothing changes:
306047827 : MQTT : Connected to broker
306047832 : Subscribed to: /oturma_grubu/#
306076814 : WD : Uptime 5101 ConnectFailures 18188 FreeMem 27880
306076814 : MQTT : Connection lost
306077834 : MQTT : Connected to broker
306077838 : Subscribed to: /oturma_grubu/#
306106815 : WD : Uptime 5101 ConnectFailures 18190 FreeMem 27880
306106815 : MQTT : Connection lost
306107848 : MQTT : Connected to broker
306107851 : Subscribed to: /oturma_grubu/#

User avatar
SuperToma
Normal user
Posts: 14
Joined: 08 Apr 2016, 08:33

Re: MQTT : Failed to connected to broker

#26 Post by SuperToma » 25 Jun 2016, 23:26

Somebody can post the compiled (.bin 512k) version 91 ? :roll:

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: MQTT : Failed to connected to broker

#27 Post by JR01 » 26 Jun 2016, 10:30

Are you able to connect with mqtt spy to mqtt server?
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

sozkara
Normal user
Posts: 14
Joined: 02 Jun 2016, 09:07

Re: MQTT : Failed to connected to broker

#28 Post by sozkara » 26 Jun 2016, 15:22

I'm using MQTT fx and yes i can connect to broker no problem.
I think it has to do with that i changed boot state of the GPIO pin i use(12) to output low. I changed it back to default. Now the problem seems to be solved. Or that i manually rebooted the device. Time will tell

wutu
Normal user
Posts: 35
Joined: 05 Feb 2016, 07:33

Re: MQTT : Failed to connected to broker

#29 Post by wutu » 28 Jun 2016, 09:50

I have the same problem with the R108. As sozkara.

User avatar
SuperToma
Normal user
Posts: 14
Joined: 08 Apr 2016, 08:33

Re: MQTT : Failed to connected to broker

#30 Post by SuperToma » 04 Jul 2016, 23:09

My ESP still can't connect to broker... :(

1/ My broker is running well :

Code: Select all

Toma@raspberrypi:~ $ ps aux | grep mos
mosquit+   338  0.1  0.8   5080  3580 ?        S    20:17   0:02 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
pi        4957  0.0  0.3   4244  1660 pts/0    S+   20:50   0:00 grep --color=auto mos
2/ I can connect & send fake messages to my broker via MQTT.fx :
Capture d’écran 2016-07-04 à 22.53.25.jpg
Capture d’écran 2016-07-04 à 22.53.25.jpg (39.89 KiB) Viewed 43084 times
Then I receive them well :

Code: Select all

Toma@raspberrypi:~ $ sudo mosquitto_sub -t /#
HELLO !!!
Here is my ESPEasy configuration :
Capture d’écran 2016-07-04 à 22.55.03.jpg
Capture d’écran 2016-07-04 à 22.55.03.jpg (134.07 KiB) Viewed 43084 times
And here is my log :
Capture d’écran 2016-07-04 à 22.59.12.jpg
Capture d’écran 2016-07-04 à 22.59.12.jpg (98.26 KiB) Viewed 43084 times
My ESPEasy version is R78
I also tried with versions R107 & R91 and I have exactly the same problem...
Strangely I prefer R78, other versions make my board a little bit noisy, the board make a little shrill noise.

My Mosquitto version is 1.3.4-2 :

Code: Select all

Toma@raspberrypi:~ $ dpkg -s mosquitto
Package: mosquitto
Status: install ok installed
Priority: optional
Section: net
Installed-Size: 186
Maintainer: Roger A. Light <roger@atchoo.org>
Architecture: armhf
Version: 1.3.4-2
Description: MQTT version 3.1/3.1.1 compatible message broker
 This is a message broker that supports version 3.1 and 3.1.1 of the MQTT
 protocol.
If anybody can help me...
Best Regards.

User avatar
SuperToma
Normal user
Posts: 14
Joined: 08 Apr 2016, 08:33

Re: MQTT : Failed to connected to broker

#31 Post by SuperToma » 05 Jul 2016, 13:27

I think I have found the solution... :|
My controller IP adress is not 192.168.0.100 but 192.168.1.100 :oops:
I'll check it tonight @home and send you reply.

Code: Select all

90% of problems are located between the chair and the keyboard...

User avatar
SuperToma
Normal user
Posts: 14
Joined: 08 Apr 2016, 08:33

Re: MQTT : Failed to connected to broker

#32 Post by SuperToma » 05 Jul 2016, 20:58

All is good for me with :
Mosquitto version 1.3.4-2
ESPEasy R78

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: MQTT : Failed to connected to broker

#33 Post by tozett » 05 Jul 2016, 21:35

your esp-modules are on your net 192.168.1.x,
and your mosquitto-server is in a different net 192.168.0.x
(look at your screenshots).
are you shure, you can reach clients from one net on the other?
maybe you check your networking-setup regarding this routing?
----
oop,s sorry . didnt saw your postings...

ut1545
Normal user
Posts: 32
Joined: 22 Mar 2016, 20:56

Re: MQTT : Failed to connected to broker

#34 Post by ut1545 » 06 Jul 2016, 21:11

Hello all,

I have found this problem in all versions that I have tried since R78. Once ESP Easy lost the IP connection with MQTT broker, it can't connect again entering in a infinite loop. Doesn't matter if the ESP lost wifi connection or MQTT server goes down. I have tried to change the ESP Easy code in order to increase the time between reconnections attempts. The original value is 500 milliseconds and I changed it to 5000 without success.

Also, I have write some simple code to publish some sensor values using MQTT in a very similar way that ESP Easy do but using the last MQTT libraries. Everything works very well.

So, my theory is that the MQTT library used by ESP Easy (Nick O'Leary Version 1.9.1) is causing the problem. In my small test program I'm using last version 2.6.0. The problem is that if you try to compile ESP Easy with the last MQTT library, you will get a lot of compilations errors and unfortunately, my C++ programing skills are very poor and insufficient to change a complex code like ESP Easy and contribute with this awesome project...

Martinus

Re: MQTT : Failed to connected to broker

#35 Post by Martinus » 13 Jul 2016, 17:22

ut1545 wrote:Hello all,

I have found this problem in all versions that I have tried since R78. Once ESP Easy lost the IP connection with MQTT broker, it can't connect again entering in a infinite loop. Doesn't matter if the ESP lost wifi connection or MQTT server goes down. I have tried to change the ESP Easy code in order to increase the time between reconnections attempts. The original value is 500 milliseconds and I changed it to 5000 without success.

Also, I have write some simple code to publish some sensor values using MQTT in a very similar way that ESP Easy do but using the last MQTT libraries. Everything works very well.

So, my theory is that the MQTT library used by ESP Easy (Nick O'Leary Version 1.9.1) is causing the problem. In my small test program I'm using last version 2.6.0. The problem is that if you try to compile ESP Easy with the last MQTT library, you will get a lot of compilations errors and unfortunately, my C++ programing skills are very poor and insufficient to change a complex code like ESP Easy and contribute with this awesome project...
So let's see if upgrading to 2.6. makes a difference to solve the issues. Can you pull R109 from github, compile using the 2.6 library and see if it works better than the old library?

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: MQTT : Failed to connected to broker

#36 Post by tozett » 13 Jul 2016, 19:25

i compiled just for me wemos-d1 mini,
with pubsubclient v2.6 on arduino-ide 1.6.5 and platform 2.1.0 without bigger issues.

only this little hint poped up:

Code: Select all

C:\Users\olaf\AppData\Local\Temp\build7720517566021989786.tmp\ESPEasy.cpp -o C:\Users\olaf\AppData\Local\Temp\build7720517566021989786.tmp\ESPEasy.cpp.o 
_P001_Switch.ino: In function 'boolean Plugin_001(byte, EventStruct*, String&)':
_P001_Switch.ino:235:31: warning: NULL used in arithmetic [-Wpointer-arith]
C:\Users\olaf\AppData\Roaming\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++ -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ -IC:\Users\olaf\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.1.0/tools/sdk/include -c -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections -DF_CPU=80000000L -DARDUINO=10605 -DARDUINO_ESP8266_ESP12 -DARDUINO_ARCH_ESP8266 -DESP8266 -IC:\Users\olaf\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.1.0\cores\esp8266
did not yet tested mqtt...but complie was ok..

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: MQTT : Failed to connected to broker

#37 Post by tozett » 13 Jul 2016, 19:35

i left all the same, but updated board manager to esp-plattform 2.3.0 and compiled ok with this warnings:

Code: Select all

-IC:\Users\olaf\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266HTTPUpdateServer\src -ID:\daten\olaf.arduino\arduino-1.6.5-r5\libraries\IRremoteESP8266 C:\Users\olaf\AppData\Local\Temp\build6597881346912999724.tmp\ESPEasy.cpp -o C:\Users\olaf\AppData\Local\Temp\build6597881346912999724.tmp\ESPEasy.cpp.o 
ESPEasy.ino:227:0: warning: "LWIP_OPEN_SRC" redefined [enabled by default]
<command-line>:0:0: note: this is the location of the previous definition
_P001_Switch.ino: In function 'boolean Plugin_001(byte, EventStruct*, String&)':
_P001_Switch.ino:235:31: warning: NULL used in arithmetic [-Wpointer-arith]
C:\Users\olaf\AppData\Roaming\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++ -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ -IC:\Users\olaf\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.3.

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: MQTT : Failed to connected to broker

#38 Post by tozett » 13 Jul 2016, 19:38

i set plattform to 2.2.0 and got a build, but with the same hints as in 2.1.0

Code: Select all

ID:\daten\olaf.arduino\arduino-1.6.5-r5\libraries\IRremoteESP8266 C:\Users\olaf\AppData\Local\Temp\build6597881346912999724.tmp\ESPEasy.cpp -o C:\Users\olaf\AppData\Local\Temp\build6597881346912999724.tmp\ESPEasy.cpp.o 
_P001_Switch.ino: In function 'boolean Plugin_001(byte, EventStruct*, String&)':
_P001_Switch.ino:235:31: warning: NULL used in arithmetic [-Wpointer-arith]
C:\Users\olaf\AppData\Roaming\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++ -D__ets__ -DICAC
did not uploaded yet to test....but binaries are build...

ut1545
Normal user
Posts: 32
Joined: 22 Mar 2016, 20:56

Re: MQTT : Failed to connected to broker

#39 Post by ut1545 » 13 Jul 2016, 22:24

Hi all,

I have tested the R109 with 2.6 library and everything seams to work ok. After the IP connection to the broker has been restored, ESP Easy reconnects immediately and stays connected.

I will continue to test this version and will keep all of you informed.

Good work Martinus and thank you very much.

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: MQTT : Failed to connected to broker

#40 Post by JR01 » 04 Aug 2016, 21:23

Okay, now I feel like an idiot..... Last time I compiled & uploaded successfully was R108. Seams we have new good stuff, MQTT pubsubclient v2.6, LWT with subscribe MQTT <template>/status, etc.

Downloaded Arduino 16.10 (last successful one I sed was 1.6.8), upgraded boards manager to v2.3.0.

But compile complains ..... fatal error: PubSubClient.h: No such file or directory #include <PubSubClient.h>

So, where on earth do I find pubsubclient v2.6 ? Stable version R108 - under directory Source/Libraries/pubsubclient/ seams to be the 1.9 version?

So where do I find v2.6 ?

(thank you, search high and low, on this forum and net, cannot find it?)
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: MQTT : Failed to connected to broker

#41 Post by JR01 » 04 Aug 2016, 21:52

//Feel like an idiot// - for not finding pubs v2.6.

Found it - Arduino menu > Sketch > Include Library > Manage Libraries.

(Maybe this helps others......)
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

hamster
Normal user
Posts: 62
Joined: 27 Sep 2015, 21:01
Location: UK

Re: MQTT : Failed to connected to broker

#42 Post by hamster » 06 Aug 2016, 16:34

FYI, for anyone with the same issue I had..

I treated myself to a cubietruck 5 last weekend, running Lubuntu; I managed to get everything working with the exception of MQTT (mqtt installed fine and the service was running and I could publish to the broker using another remote Domoticz server also node_red connected to ok, but the ESP would not connect.
After some time googling I found that by adding the following into the repository,
https://mosquitto.org/2013/01/mosquitto ... epository/

Code: Select all

sudo nano /etc/apt/sources.list
adding the following line

Code: Select all

deb http://repo.mosquitto.org/debian /wheezy main trusty main restricted
Save and update

Code: Select all

sudo apt-get update
this updated mosquitto and is now working fine 8-)

Post Reply

Who is online

Users browsing this forum: No registered users and 50 guests