MQTT Disconnects ESP8266

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Rampler
Normal user
Posts: 95
Joined: 31 Dec 2016, 07:13

MQTT Disconnects ESP8266

#1 Post by Rampler » 04 May 2022, 15:14

Hi all,
i use ESP8266 with actual Software.
From time to time i get a event MQTT#Disconnect (every 1-2 hours). I am using PIDOME MQTT.
Broker is runnung under Raspberry Buster. mosquitto version 2.0.11

The log on my MQTT Broker says:
1651661432: Client Wohnzimmer_LCD_5 has exceeded timeout, disconnecting.
1651661432: New connection from 192.168.1.24:63600 on port 1883.
1651661432: New client connected from 192.168.1.24:63600 as Wohnzimmer_LCD_5 (p2, c0, k10).

Any hints for me ?
ESP8266 have a rssi of -57db

regards Klaus

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MQTT Disconnects ESP8266

#2 Post by TD-er » 04 May 2022, 15:31

What do you have configured as timeout on the controller settings for your PiDome MQTT controller?
Is the MQTT broker on the local network?

Rampler
Normal user
Posts: 95
Joined: 31 Dec 2016, 07:13

Re: MQTT Disconnects ESP8266

#3 Post by Rampler » 04 May 2022, 16:41

Client Timeout is set to 1000 ms. (is this the PingReq timeout ?)
Broker is in the same subnet via repeater ..

EDIT:
Periodical send Gratuitous ARP is on
Force WiFi B/G is also on
Send With Max TX Power yes
Force WiFi No Sleep: yes

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MQTT Disconnects ESP8266

#4 Post by TD-er » 04 May 2022, 21:57

Can you take a look at the timing stats?
N.B. the timing stats must be included in the build, for 1M builds or "testing" builds it isn't. You also need to enable it on the Tools-Advanced page to actually collect the timing stats.

Rampler
Normal user
Posts: 95
Joined: 31 Dec 2016, 07:13

Re: MQTT Disconnects ESP8266

#5 Post by Rampler » 05 May 2022, 07:18

OK, i have activated the timing stats. Which value do you need ?

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MQTT Disconnects ESP8266

#6 Post by TD-er » 05 May 2022, 09:36

Well any that 'jumps out'.
Better show the entire page as it is hard to tell up front which value matters.

N.B. the timing stats are reset on every reload of the page.

Best to reload the page once and then leave it running for a while. Preferrably at least 2 - 3 "disconnects".
Do not load pages inbetween as serving web pages may also handle while other actions are processed, which may cause high values in the stats where they are not related to the actual action.

Another thing you can test, to see if it makes a difference, is sending a continuous ping from just any host in the network to the ESP and see if the unit remains connected to the broker for a longer time.

Also check the sysinfo page to see if the ESP may have been reconnecting to WiFi.

Rampler
Normal user
Posts: 95
Joined: 31 Dec 2016, 07:13

Re: MQTT Disconnects ESP8266

#7 Post by Rampler » 05 May 2022, 20:22

IMHO, i see only:
rulesProcessing() 264 0.46 10.54 80.530 226.881 3609.560

Here are my rules:

rules1.txt

Code: Select all

on System#Boot do
 timerSet,1,1           // Init Display after 1 Seconds
 lcdcmd,off 
 pwm,5,200
 Let 1,200
 notify 1
endon

on Rules#Timer=1 do     // Wait until MQTT is connected
 lcdcmd,on              // Start if message MQQT connect apears
 lcd,1,1,Waiting... 
 lcd,2,1,Waiting...
endon

on MQTT#Connected do     // Start Display wrap around 
  timerSet,2,3
endon

on MQTT#Disconnected do  // Reset Display when ESP are disconnected ..
 timerSet,2,0
 timerSet,3,0
 timerSet,4,0
 timerSet,5,0
 timerSet,6,0
 notify 1
 lcd,1,1,'MQTT disconnect!'
 lcd,2,1,'be cool ..   '
endon

on Rules#Timer=2  do
 lcd,1,1,'Wind [MQTT_IMPORT1#ws] km/h     x' 
 lcd,2,1,'%sysweekday_s% %sysday%-%sysmonth%-%sysyear%     x'
 timerSet,3,3
endon

on Rules#Timer=3  do
 lcd,1,1,'Out T:[MQTT_IMPORT1#out_temp] H:[MQTT_IMPORT1#out_hum]   x'
 lcd,2,1,'In  T:[T&H#in_temp] H:[T&H#in_hum]    x'
 timerSet,4,3
endon

on Rules#Timer=4  do
 lcd,1,1,'Rain [MQTT_IMPORT1#Raintoday] l/qm   x '  
 lcd,2,1,'CO2  [CO2#CO2] ppm     x'
 timerSet,5,3
endon

on Rules#Timer=5  do
 lcd,1,1,'APS-A [MQTT_IMPORT2#Pressure] hPA      x'
 lcd,2,1,'Time  %systime%     x'
  timerSet,6,3
endon

on Rules#Timer=6  do
   if [MQTT_IMPORT2#Tendency] > 0
    lcd,1,1,'APS-T +[MQTT_IMPORT2#Tendency] (3h)    x'
  else
    lcd,1,1,'APS-T [MQTT_IMPORT2#Tendency] (3h)    x'
  endif
  lcd,2,1,'SR %sunrise% SS %sunset% '
  timerSet,2,3
endon

//
// CO2 Steuerung:
//
on CO2#co2 do 
 if [CO2#co2] > 2000 
      tone,4,2100,6000
 endif
 if [CO2#co2] > 1000 and [CO2#co2] < 2000
      tone,4,2100,3000
 endif
endon
rules2.txt

Code: Select all

on LDR#Light do
 If [LDR#Light] >550 and  [LDR#Light] <650 and [VAR#1] != 20
  pwm,5,20,3000
  Let 1,20
 endif
 If [LDR#Light] >650 and  [LDR#Light] <750 and [VAR#1] != 40
  pwm,5,40,3000
  Let 1,40
 endif
 If [LDR#Light] >750 and  [LDR#Light] <900 and [VAR#1] != 50
  pwm,5,50,3000
  Let 1,50
 endif
 If [LDR#Light] >900 and  [LDR#Light] <1010 and [VAR#1] != 100
  pwm,5,100,3000
  Let 1,100
 endif
 If [LDR#Light] >=1010  and  [VAR#1] != 800
  pwm,5,800,3000
  Let 1,800
 endif
 If [LDR#Light] <=550 and  [VAR#1] != 10
  pwm,5,10,3000
  Let 1,10
 endif
endon

//on Clock#Time=All,**:00 do   //**:** ==> jede Minute  **:00 ==> jede Stunde
// tone,4,2100,500
//endon
Next, i will try the ping the ESP permanent, and i will try to connect the ESP to different Access Point.

regards Klaus
Attachments
Screenshot 2022-05-05 at 20-12-46 Wohnzimmer_LCD.png
Screenshot 2022-05-05 at 20-12-46 Wohnzimmer_LCD.png (302.79 KiB) Viewed 5723 times

User avatar
Ath
Normal user
Posts: 3488
Joined: 10 Jun 2018, 12:06
Location: NL

Re: MQTT Disconnects ESP8266

#8 Post by Ath » 05 May 2022, 20:34

That build is 4 months old, in the latest build 20220427 the rules processing has been performance-improved, that might help you here.

Is this disconnect-behavior new, or have you seen this since the December 24 install, or even before that? (the rules look quite 'mature', so I expect that this setup has been running for a longer time already ;))
/Ton (PayPal.me)

Rampler
Normal user
Posts: 95
Joined: 31 Dec 2016, 07:13

Re: MQTT Disconnects ESP8266

#9 Post by Rampler » 05 May 2022, 20:58

I am not sure, but as far as i remember the disconnect-behavior is very old.
The difference is, that i connected a buzzer to the ESP8266 this week, and since that time, i noticed the "problem".
I will give i try with the build 20220427 ...

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MQTT Disconnects ESP8266

#10 Post by TD-er » 05 May 2022, 23:25

The tone command may be rather blocking for quite a while.
Can you test with the tone command commented-out to see if that makes the MQTT connection more stable.

Another "dirty" work-around is to call publish something to the MQTT broker right before calling the tone command.

Rampler
Normal user
Posts: 95
Joined: 31 Dec 2016, 07:13

Re: MQTT Disconnects ESP8266

#11 Post by Rampler » 07 May 2022, 07:01

The latest build 20220427 fixed my Problem. Right now 24 hours no disconnects.
Thank you all very much for your support !!

best ragrards
Klaus

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MQTT Disconnects ESP8266

#12 Post by TD-er » 07 May 2022, 11:20

Great!

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests