Black Lives Matter - Action and Equality.
0

frequent offline event
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

frequent offline event

by cbfraser on Wed Apr 29, 2020 11:50 am

I have a simple client -ESP8266 LUA-using MQTT subscribing to a single feed. It works well but I notice it goes offline about once per minute with no data coming in on the feed and no other code being executed.
I catch this with mqtt:on('offline'.... to redo the connection. The reconnect is always successful, and reads when there is data are correct. But data might be missed during offline/connection blip. Is this frequent offline event to be expected? Unit has strong WIFI signal.

cbfraser
 
Posts: 8
Joined: Sun Apr 05, 2020 8:16 pm

Re: frequent offline event

by brubell on Wed Apr 29, 2020 12:10 pm

If you're using MQTT, you may want to add a add a frequent PING to your LUA/MQTT Client. The client may have a keep-alive interval, try increasing it.

for more information: http://www.steves-internet-guide.com/mq ... y-example/

brubell
 
Posts: 891
Joined: Fri Jul 17, 2015 10:33 pm

Re: frequent offline event

by cbfraser on Thu Apr 30, 2020 9:37 pm

I have changed keep alive on the client to 30
mqtt = mqtt.Client('esp8266', 30, username, aioKey)

and ping by publishing to the feed every 30 seconds

fairly consistent offline event every 60 seconds
with "pings" inbetween - see below

also fyi - receiving time/seconds

any other suggestions?

2020/4/30 18:29:31 offline
2020/4/30 18:29:31 connected
# of connections: 11
topic: cbfraser/feeds/garage.garage
topic: time/seconds
topic: cbfraser/errors
subscribe success
subscribe success
subscribe success
2020/4/30 18:29:33: ping sent!

data in: ping
data out: ping
2020/4/30 18:30:3: ping sent!

data in: ping
data out: ping
2020/4/30 18:30:31 offline

cbfraser
 
Posts: 8
Joined: Sun Apr 05, 2020 8:16 pm

Re: frequent offline event

by brubell on Fri May 01, 2020 9:36 am

Could you try pinging the server more frequently than every 30sec, maybe ever 10sec?

When you visit your feed monitor page (http://io.adafruit.com/monitor), do feeds disconnect immediately after subscribing to them, or after you publish data to them?

brubell
 
Posts: 891
Joined: Fri Jul 17, 2015 10:33 pm

Re: frequent offline event

by cbfraser on Fri May 01, 2020 11:11 am

ping (posting data) every 10 seconds - still regular disconnect every 60 seconds
disconnect not in sync with posting

monitor pages shows connect/disconnect trail and ping data

==================
2020/5/1 7:53:53 offline
2020/5/1 7:53:53 connected
# of connections: 2
topic: cbfraser/feeds/garage.garage
topic: time/seconds
topic: cbfraser/errors
subscribe success
subscribe success
subscribe success
2020/5/1 7:53:58: ping sent!

data in: ping
data out: ping
2020/5/1 7:54:8: ping sent!

data in: ping
data out: ping
2020/5/1 7:54:18: ping sent!

data in: ping
data out: ping
2020/5/1 7:54:28: ping sent!

data in: ping
data out: ping
2020/5/1 7:54:38: ping sent!

data in: ping
data out: ping
2020/5/1 7:54:48: ping sent!

data in: ping
data out: ping
2020/5/1 7:54:54 offline
2020/5/1 7:54:54 connected

cbfraser
 
Posts: 8
Joined: Sun Apr 05, 2020 8:16 pm

Re: frequent offline event

by cbfraser on Fri May 01, 2020 12:59 pm

and if I strip out subscriptions to time and errors - just the one feed
with no publishing and no other data posted by other clients -
still nice & regular offline/connect about every 60 seconds.....

anything else to try to isolate problem?

thanks

cbfraser
 
Posts: 8
Joined: Sun Apr 05, 2020 8:16 pm

Re: frequent offline event

by brubell on Mon May 04, 2020 9:51 am

Could you try rebooting your router?

Also - try setting the pings to every 29sec.

brubell
 
Posts: 891
Joined: Fri Jul 17, 2015 10:33 pm

Re: frequent offline event

by cbfraser on Sun May 17, 2020 2:02 pm

rebooted router
publishing data to a subscrbied feed every 10 seconds
subscribed to time/seconds - so receiving every second
keepalive 10 seconds

disconnect very regular 60 seconds

and switch internet connecto to mobile data so router not involved - same behavior

arduino code doing similar subscription to time/seconds - doesn't have problem

so must be a lua /esp8266 issue... I'll just have to work around

thanks for the help

cbfraser
 
Posts: 8
Joined: Sun Apr 05, 2020 8:16 pm

Please be positive and constructive with your questions and comments.