BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Server connection dropouts


#1

I’ve been running a project which is working well but I cannot stay connected to the Blynk server for more than 12-18 hours. Here is the readback message on my Serial monitor. When this occurs, I have to cycle the power on my device and allow it to reconnect. Any ideas what is causing this?

[9087633] Ready (ping: 218ms).
[9779171] Heartbeat timeout
[9782174] Connecting to blynk-cloud.com:80


C++ Blynk - Code Examples for Basic Tasks (Work in Progress)
#2

Meens your sketch is probably doing something that takes longer then the heartbeat (typically 10 seconds) and causing the timeout. Or something is causing some device issue. Or power related, or, or, or…

This is not a Blynk bug, more a coding/localised issue. But without even seeing your code (properly formatted for forum viewing - see the Welcome topic) all we can do is guess.


#3

Hi, is there a way to monitor the Heartbeat on the Serial monitor?


#4

While not ideal for long term, you should see it with the Debug command

http://docs.blynk.cc/#blynk-firmware-debugging-define-blynk_debug


#5

Hi
I’ve set up two ESP32 boards on different power supplies, one is running my sketch and the other is running a stock standard example sketch from the library file. Both boards lost connection to the server at exactly the same time (04:02am), so it is not the sketch or the board or the power supply. This leaves either the router or the internet connection or the Blynk server.

I also have a Cayenne board running continuously which has not exhibited any disconnection issues, so that appears to rule out the router and the internet connection, leaving the Blynk server.

My concern is that the ESP32 boards are unable to reconnect to the server after a dropout. As you can see from the original post, the board is trying to connect to the server, but never succeeds. It continually attempts, giving this message over and over again

[9779171] Heartbeat timeout
[9782174] Connecting to blynk-cloud.com:80

Any thoughts??


#6

Is it also running on an ESP32?

The ESP32 is still a bit of a work in progress for espressif, let alone Blynk and/or other applications.

Have you tried running a ESP8266 board alongside the ESP32s and see if it also drops at same time?


#7

The Cayenne board is an Arduino Mega with Cat 6 connection to the same router as the two ESP32s


#8

OK, so totally different processor, router connection and server platform… kind of takes it out of the proper troubleshooting loop :wink: Like saying “I can connect to the internet and this forum fine through my router… so a failing Blynk setup must be the servers fault:stuck_out_tongue_winking_eye:

More likely some localised interference in the WiFi… and yes, without proper coding, a reconnection may not automatically happen without reboot.

And hard to say what a proper reconnection routine looks like on an ESP32 as it uses WiFi on separate core.

I have an ESP32 running 24/7 that also seems to loose connection once in awhile… I have it set to keep running the script and attempt reconnection, but it is not always successful. Basicly a coding issue, not a Blynk issue.


#9

Ok thanks very much. Interesting to hear that you are seeing the same (or similar) dropouts on occasions.


#10

Dropouts from interference are the nature of WiFi, and not just with ESP32 either, and mentioned all over this forum. Thus the whole need for various reconnection routines in the first place.


#11

Try adapting this for ESP32 and see it it works for you…


#12

Thanks very much. I will give it a go


#13

@Gunner, You have been busy. Thanks so much for all these tips, tricks, and ideas. I’ve learned a great deal reading this one thread alone.


#14

In several sketches you defined a heartbeat variable = 60. Does the Heartbeat return a variable (1 or 0) if received within the designated time frame?


#15

It probably slipped in from copy/pasting snippets to and from other more complex sketches I run. EDIT - actually those vLED sketches are rather communication heavy with lots of fast Blynk.virtualWrites()… that is why I was testing a handful of “helper” commands… but most probably only work for Local Server application anyhow.

It is in reference to setting the timeout disconnection & indicator… and can generally can be left out of the sketch for the default of 10 seconds…

http://docs.blynk.cc/#blynk-main-operations-devices-online-status

If you know you have a lot going on and that your connection may run late, you can set it a little longer so that it the server will simply assume it is still connected. I don’t believe it returns any user accessible boolean values though, aside from telling the App that the device is offline…


#16

thanks for that. Appreciate the quick reply


#17

No problem. FYI, I will move these last few posts into one of your relevant topics.

PS glad you liked the code examples… thank you for the appreciation! :smiley: