Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Lost connection to MQTT bruker, reconnect automatically.
#11
I've had some similar connection issues on the websockets front. Since sometimes it's just inevitable, I added a webserial Virtuino debugging/abort code to all my projects. It's intranet only, but for those hard to reach ESP's, I can pull up a serial monitor on my desktop, see what the ESP is doing, and tell the ESP to restart so Virtuino can reestablish connection. I can write up a quick tutorial if you guys would like it.
Reply
#12
Hi,
after several tests I found this malfunction and fixed it.
The changes will be made in the next update (0.6.18) which will be made in the following days.
Reply
#13
Thumbs Up 
(11-01-2023, 12:18 AM)iliaslamprou Wrote: Hi,
after several tests I found this malfunction and fixed it.
The changes will be made in the next update (0.6.18) which will be made in the following days.

Nice, thank you Ilias
Reply
#14
Hi again.

Very satisfied with Virtuino runing on both Linux Mint and Android but this minor culprit still exists... Loosing connection/updating every now and then. It it far better than when this thread started but still not quite ok.

I have a variable that is updating AT LEAST every minute. Is it possible to create a script that disconnect/reconnect MQTT if this variable is not updated after f.ex. 5 minutes? If so, how?
Reply
#15
(05-28-2024, 10:55 AM)SveinHa Wrote: Hi again.

Very satisfied with Virtuino runing on both Linux Mint and Android but this minor culprit still exists... Loosing connection/updating every now and then. It it far better than when this thread started but still not quite ok.

I have a variable that is updating AT LEAST every minute. Is it possible to create a script that disconnect/reconnect MQTT if this variable is not updated after f.ex. 5 minutes? If so, how?

I think you can do it without javascript.
You need two "Timers" for this and three "If Then" scripts.
You can disconnect but you have to find another way to connect to the broker again.
This is a video example: https://virtuino.com/downloads/videos/mq...onnect.mov
Reply
#16
Hi all.

I finally spent a few hours experimenting with the lost update problem. It have taken a long time because the problem have not been a major one. Since the start of this thread, the communication have been improving quite a lot.

My solution is like this:

  1. Add a mqtt variable that is frequently updated. I went for "$SYS/broker/messages/received" which is an integer updated every 10 sec.
  2. Added a timer that is always running and updating a variable every second:     
  3. A javascript sets timer to 0 on receive of new message:     
  4. An If-Then performs a DisConnect when counter/timer reaches 100:     
  5. An If-Then performs a Connect when counter/timer reaches or passes 104:     
  6. Probably not nessesary but I also have a javascript that reset counter/timer if it reaches 105:     

I have tested a few times by restarting my Mosquitto Broker and the counter/timer counts up to 104 with no updates and then all variables come to life. Real life testing starts today...

When I reboot my Mosquitto Broker, the connection status go from 1 to 3 and when the broker is up and running again it go back to 1. At that point in time, the counter/timer resets once but no updates is seen in other variables. I might have used quite a bit shorter delay but nowadays there is at least many hours and upto several weeks between every communication failure so the long time is no problem. 

I also have noted that one of two Android tablets is far more prone to communication failure even when they are located fairly close to each other in very good WiFi coverage.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)