Login time out and heartbeat

I live in a densely populated area of China and the ping value (during the day) is typically 1200+ ms and can sometimes be well over 2000ms. I have confirmed this by pinging blynk-cloud.com direct.

I have 2 projects running in my home and during the day they often disconnect and reconnect due to heartbeat and then login timeout. I know it is my home Internet connection and not my hardware/software because if I move the project to my company office it runs continuously without any problem, the ping value there is around 45ms.

Is it possible to increase the heartbeat time and the login time out? I have trawled through this forum to try and find an answer but without success.




As well as mentioned in the Docs…



@Gunner correct me if I’m wrong here because I’ve truly tried many things (including your suggestion above) mentioned in forum posts and the Blynk documents, asking for help has been my last resort.

As I understand it ,the problem is not the heartbeat period but the response time due to a very slow internet speed. During the day (anytime between 7am and 11:30pm) my 2 projects run, but constantly have “heartbeat time out” and “login time out” events, they do eventually connect for a short period (5 minutes to 1 hour) before again having a heartbeat time out. During the night both have a continuous connection with no time out events. If I take both projects to another location with a faster internet speed then I have no problem.


Well… You originally asked if there’s a way to increase your heartbeat timeout and as Gunner said try:

// Heartbeat period in seconds.
#define BLYNK_HEARTBEAT      10

But you said your internet provider doesn’t deliver a good link and your ping is 2000ms there’s nothing we can do about it.

And I remember someone from China mentioning in the past some port/server block.

1 Like

@rha10 Setting up your own Local Server may be your only other option.

I’ve done a bit more investigation into my Blynk connection problem here in China, firstly my Internet provider tell me that they cannot increase the service and I have the best they they can do.

I’ve also done some diagnostic work on my project to see if there is a reason to the continued heartbeat timeout with some interesting results. I inserted a small bit of code (from @Gunner I think) to measure the loop cycles per second and MCU up time (millis) and send the data to Blynk every 1 second.

The first noticeable thing is that now my project remains connected for many hours before any timeout issues, the original main sketch sends data to Blynk every 15 seconds but now I send MCU data (3 vPins) every 1 second it is very much more stable. In the past 9 hours I’ve only had 2 re-connection events which is good, usually I’m lucky to go 30 minutes without a timeout event! The only conclusion I can think of, because nothing else has changed (ping value still typically 1000+ ms), is that by pushing data to Blynk every 1 second a good connection is being maintained.

The other interesting event that can be seen in the screen shot is that I had an MCU reset, or at least the millis reset back to zero after about 330 minutes (not 49 days!), there were 2 Blynk connection events one either side but 23 minutes apart and the millis reset did not affect the connection status. If the MCU had of gone through a reset routine I would have expected a longer disconnected period that coincided with the reset. Can the millis counter reset back to zero without an actual MCU reset? Not a Blynk question I know but Blynk has helped me great deal to diagnose these events.


But several things can trigger a MCU reset as power problems or software watchdogs.

You should also take a look at BLYNK_TIMEOUT_MS

@vshymanskyy thanks for your input and suggestion.

I’ve tried altering the timeout value but it made no difference


This is now the best result I’ve ever had, nearly 5.5 hours with only 1 re-connection. Pushing data to the Blynk server every 1 second keeps the connection going.


which BLYNK_TIMEOUT_MS did yo u set? 2000 will not be enough. use 5K-6K in your situation

maybe even decrease the BLYNK_HEARTBEAT to 3-5 sec, if it keeps your connection stable.

@vshymanskyy Okay thanks, I will try increasing the timeout to 5K+, 2K was the highest value I tried and it made no difference.

Looks like I made a mistake with the heartbeat, I only tried increasing the value NOT decreasing it!!!