[SOLVED] Reliability of connections to Blynk (using Cloud Server over Satellite Internet)

I am new to Blynk, but I have been using Aduino for a few years.
I am using a WeMos D1 mini Pro programmed with the Arduino IDE version 1.6.12 running on a thinkpad laptop T420 with linux Manjaro (just to give you some context).
I downloaded the sample program BlynkPushData.ino from your website, which runs with no apparent problems.
I then added some extra virtual pins, and observed some intermittent gaps in the transmission. So I added some Serial.print() statements and some variables to track what was going on.
With this version using 4 virtual pins, my success rate in pushing data to Blynk-cloud seems to be about 50%, sometimes worse.
Also the time taken for Blynk.begin() can be very long - I have seen over 4 minutes before it returns.
I will attach my code, which I regard as being non-contentious modifications of yours; and a text file which is the result of capturing the Serial.print() output. I have several more such files if they will help.
As near as I can tell by eye, when the “connected” flag is True, I get to see the value on my mobile phone; and when it is False, there is no update of the value on my mobile phone.

My questions are:
a) is there something I am doing wrong, that is causing this intermittent connection?
b) If I am not doing something wrong, is there something I can do to improved the performance (I have tried using Blynk.connect() and will explore that further unless you advise me otherwise).
c) can you explain the multi-minute response time for Blynk.begin()?
Thank you in advance.

I can’t see how to attach files, so I will just paste them in line:
Here is my code, which I have called BlynkPushDataV2.ino:
I have edited out my authorisation code and my WiFi password. I doubt if you need them.

/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************

  This example shows how value can be pushed from Arduino to
  the Blynk App.

  NOTE:
  BlynkTimer provides SimpleTimer functionality:
    http://playground.arduino.cc/Code/SimpleTimer

  App project setup:
    Value Display widget attached to Virtual Pin V5
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "8xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "tanderra";
char pass[] = "xxxxxxxxxx";

long cycles = 0;
long notConnectedCount0 =0 ;
long notConnectedCount1 =0;
long notConnectedCount2 =0;
long notConnectedCount3 =0;

BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  cycles ++;
  Serial.println ("\nTimer Event triggered");

  Serial.print ("sending millis/1000   to Blynk V0 value=");
  Serial.print (millis()/1000%1000);
  byte yesConnected = Blynk.connected();
  if (yesConnected == 0) notConnectedCount0 ++;
  Serial.print (" Blynk connection flag=");
  Serial.print (yesConnected);
  Serial.print (" millis=");
  Serial.println (millis());
  Blynk.virtualWrite(V0, millis() / 1000 %1000);


  Serial.print ("sending millis/1000+1 to Blynk V1 value=");
  Serial.print ((millis()/1000+1)%1000);
  yesConnected = Blynk.connected();
  if (yesConnected == 0) notConnectedCount1 ++;
  Serial.print (" Blynk connection flag=");
  Serial.print (yesConnected);
  Serial.print (" millis=");
  Serial.println (millis());
  Blynk.virtualWrite(V1, (millis() / 1000+1) %1000);

  Serial.print ("sending millis/1000+2 to Blynk V2 value=");
  Serial.print ((millis()/1000+2)%1000);
  yesConnected = Blynk.connected();
  if (yesConnected == 0) notConnectedCount2 ++;
  Serial.print (" Blynk connection flag=");
  Serial.print (yesConnected);
  Serial.print (" millis=");
  Serial.println (millis());
  Blynk.virtualWrite(V2, (millis() / 1000+2) %1000);

  Serial.print ("sending millis/1000+3 to Blynk V3 value=");
  Serial.print ((millis()/1000+3)%1000);
  yesConnected = Blynk.connected();
  if (yesConnected == 0) notConnectedCount3 ++;
  Serial.print (" Blynk connection flag=");
  Serial.print (yesConnected);
  Serial.print (" millis=");
  Serial.println (millis());
  Blynk.virtualWrite(V3, (millis() / 1000+3) %1000);

  Serial.print ("Not Connected counts = ");
  Serial.print (notConnectedCount0);
  Serial.print (' ');
  Serial.print (notConnectedCount1);
  Serial.print (' ');
  Serial.print (notConnectedCount2);
  Serial.print (' ');
  Serial.print (notConnectedCount3);
  Serial.print (" cycles = ");
  Serial.println (cycles);

}

void setup()
{
  // Debug console
  Serial.begin(9600);

  long beginMillis = millis();
  Serial.println ("\nBlynk.begin has started "); // added by KH
  Serial.println (beginMillis); // added by KH
  
  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
  long beginDuration = millis()-beginMillis;
  Serial.print ("\nBlynk.begin has returned after "); // added by KH
  Serial.print (beginDuration); // added by KH
  Serial.print (" ms. millis="); // added by KH
  Serial.println (millis()); // added by KH

  // Setup a function to be called every 30 seconds
  timer.setInterval(30000L, myTimerEvent); // changed to 30s, KH
} // end of setup()

void loop()
{
  Blynk.run();
  timer.run(); // Initiates BlynkTimer

}
//*********************************************************************

Now here is my last Serial.print() log file

tail 8
chks:���
Blynk.begin has started 
17746
[17746] Connecting to tanderra
[24749] Connected to WiFi
[24749] IP: 192.168.0.100
[24749] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.7 on Arduino

[24823] Connecting to blynk-cloud.com:8442
[30470] Ready (ping: 979ms).
[35472] Login timeout
[35472] Connecting to blynk-cloud.com:8442
[41691] Connecting to blynk-cloud.com:8442
[48791] Connecting to blynk-cloud.com:8442
[55865] Connecting to blynk-cloud.com:8442
[62915] Connecting to blynk-cloud.com:8442
[69965] Connecting to blynk-cloud.com:8442
[77014] Connecting to blynk-cloud.com:8442
[84064] Connecting to blynk-cloud.com:8442
[91063] Connecting to blynk-cloud.com:8442
[98063] Connecting to blynk-cloud.com:8442
[105162] Connecting to blynk-cloud.com:8442
[112237] Connecting to blynk-cloud.com:8442
[119286] Connecting to blynk-cloud.com:8442
[126386] Connecting to blynk-cloud.com:8442
[133485] Connecting to blynk-cloud.com:8442
[140560] Connecting to blynk-cloud.com:8442
[147684] Connecting to blynk-cloud.com:8442
[154834] Connecting to blynk-cloud.com:8442
[161884] Connecting to blynk-cloud.com:8442
[168983] Connecting to blynk-cloud.com:8442
[176083] Connecting to blynk-cloud.com:8442
[183207] Connecting to blynk-cloud.com:8442
[190282] Connecting to blynk-cloud.com:8442
[197506] Connecting to blynk-cloud.com:8442
[204606] Connecting to blynk-cloud.com:8442
[211680] Connecting to blynk-cloud.com:8442
[218755] Connecting to blynk-cloud.com:8442
[225854] Connecting to blynk-cloud.com:8442
[232879] Connecting to blynk-cloud.com:8442
[240029] Connecting to blynk-cloud.com:8442
[247103] Connecting to blynk-cloud.com:8442
[254253] Connecting to blynk-cloud.com:8442
[256564] Login timeout
[259564] Connecting to blynk-cloud.com:8442
[266327] Connecting to blynk-cloud.com:8442
[273401] Connecting to blynk-cloud.com:8442
[277249] Login timeout
[280249] Connecting to blynk-cloud.com:8442
[281723] Ready (ping: 1293ms).

Blynk.begin has returned after 265136 ms. millis=282882
[297883] Connecting to blynk-cloud.com:8442
[304600] Connecting to blynk-cloud.com:8442
[311724] Connecting to blynk-cloud.com:8442

Timer Event triggered
sending millis/1000 to Blynk V0 value=318 Blynk connection flag=0 millis=318749
sending millis/1000+1 to Blynk V1 value=319 Blynk connection flag=0 millis=318803
sending millis/1000+2 to Blynk V2 value=320 Blynk connection flag=0 millis=318889
sending millis/1000+3 to Blynk V3 value=321 Blynk connection flag=0 millis=318976
Not Connected counts = 1 1 1 1 cycles = 1
[319030] Connecting to blynk-cloud.com:8442
[325948] Connecting to blynk-cloud.com:8442
[333123] Connecting to blynk-cloud.com:8442
[340222] Connecting to blynk-cloud.com:8442

Timer Event triggered
sending millis/1000 to Blynk V0 value=347 Blynk connection flag=0 millis=347272
sending millis/1000+1 to Blynk V1 value=348 Blynk connection flag=0 millis=347326
sending millis/1000+2 to Blynk V2 value=349 Blynk connection flag=0 millis=347412
sending millis/1000+3 to Blynk V3 value=350 Blynk connection flag=0 millis=347499
Not Connected counts = 2 2 2 2 cycles = 2
[347553] Connecting to blynk-cloud.com:8442
[354471] Connecting to blynk-cloud.com:8442
[361571] Connecting to blynk-cloud.com:8442
[368670] Connecting to blynk-cloud.com:8442

Timer Event triggered
sending millis/1000 to Blynk V0 value=375 Blynk connection flag=0 millis=375820
sending millis/1000+1 to Blynk V1 value=376 Blynk connection flag=0 millis=375874
sending millis/1000+2 to Blynk V2 value=377 Blynk connection flag=0 millis=375961
sending millis/1000+3 to Blynk V3 value=379 Blynk connection flag=0 millis=376047
Not Connected counts = 3 3 3 3 cycles = 3
[376101] Connecting to blynk-cloud.com:8442
[382994] Connecting to blynk-cloud.com:8442
[392269] Login timeout
[395269] Connecting to blynk-cloud.com:8442
[402018] Connecting to blynk-cloud.com:8442

Timer Event triggered
sending millis/1000 to Blynk V0 value=409 Blynk connection flag=0 millis=409043
sending millis/1000+1 to Blynk V1 value=410 Blynk connection flag=0 millis=409097
sending millis/1000+2 to Blynk V2 value=411 Blynk connection flag=0 millis=409183
sending millis/1000+3 to Blynk V3 value=412 Blynk connection flag=0 millis=409270
Not Connected counts = 4 4 4 4 cycles = 4
[409324] Connecting to blynk-cloud.com:8442
[416192] Connecting to blynk-cloud.com:8442
[423292] Connecting to blynk-cloud.com:8442
[424727] Ready (ping: 1130ms).

Timer Event triggered
sending millis/1000 to Blynk V0 value=432 Blynk connection flag=1 millis=432882
sending millis/1000+1 to Blynk V1 value=434 Blynk connection flag=1 millis=433036
sending millis/1000+2 to Blynk V2 value=435 Blynk connection flag=1 millis=433179
sending millis/1000+3 to Blynk V3 value=436 Blynk connection flag=1 millis=433966
Not Connected counts = 4 4 4 4 cycles = 5

Timer Event triggered
sending millis/1000 to Blynk V0 value=462 Blynk connection flag=1 millis=462882
sending millis/1000+1 to Blynk V1 value=466 Blynk connection flag=1 millis=465914
sending millis/1000+2 to Blynk V2 value=468 Blynk connection flag=1 millis=466078
sending millis/1000+3 to Blynk V3 value=469 Blynk connection flag=1 millis=466222
Not Connected counts = 4 4 4 4 cycles = 6

Timer Event triggered
sending millis/1000 to Blynk V0 value=492 Blynk connection flag=1 millis=492882
sending millis/1000+1 to Blynk V1 value=498 Blynk connection flag=0 millis=497884
sending millis/1000+2 to Blynk V2 value=499 Blynk connection flag=0 millis=497915
sending millis/1000+3 to Blynk V3 value=500 Blynk connection flag=0 millis=498001
Not Connected counts = 4 5 5 5 cycles = 7
[498056] Connecting to blynk-cloud.com:8442
[504712] Connecting to blynk-cloud.com:8442
[509181] Login timeout
[512181] Connecting to blynk-cloud.com:8442
[516275] Ready (ping: 1981ms).

Timer Event triggered
sending millis/1000 to Blynk V0 value=522 Blynk connection flag=1 millis=522882
sending millis/1000+1 to Blynk V1 value=525 Blynk connection flag=1 millis=524038
sending millis/1000+2 to Blynk V2 value=527 Blynk connection flag=1 millis=525085
sending millis/1000+3 to Blynk V3 value=533 Blynk connection flag=0 millis=530087
Not Connected counts = 4 5 5 6 cycles = 8
[530090] Connecting to blynk-cloud.com:8442
[534521] Ready (ping: 0ms).

Finally, here is the very last section of a much longer log file sample (formatting is slightly different due to evolution of the code, but no content change)

Timer Event triggered, Blynk connection flag=0 millis=1177232
sending millis/1000 to Blynk V0 value=177
sending millis/1000+1 to Blynk V1 value=178 Blynk connection flag=0 millis=1177288
sending millis/1000+2 to Blynk V2 value=179 Blynk connection flag=0 millis=1177375
sending millis/1000+3 to Blynk V3 value=180 Blynk connection flag=0 millis=1177463
Not Connected counts = 81 89 97 104 cycles = 231

There are 3 lines in the code that got mangled somehow. They are as per the original:

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

I don’t know why they changed - maybe it is to do with the HTML interpreter, and it will go wrong here too.

Add three backticks ` before and after your code:)

@farmerkeith looks like you have a bad network.

Which version of the Arduino core are you using? If you are on 2.4.0-rc1 roll back to 2.3.0.

As per the Welcome topic, [README] Welcome to Blynk Community!, code needs to be formatted as follows:

@Costas, thank you for the quick response.
To answer your question, I think I am on core 2.3.0.
The reason I think that, is that I have selected WeMos D1 Mini in the Boards Manager menu of the Arduino IDE (which I know is not my hardware exactly, but pretty close and there is no entry for WeMos D1 mini Pro) and there is an entry there which says “esp8266 by ESP8266 Community version 2.3.0 INSTALLED” and then a list of boards including WeMos D1 Mini but not WeMos D1 mini Pro.

As to the reason for my problems being “a bad network”, I am not so sure this is the only thing going on. But it might be. i am working on it, and will send a further report when I have more results. My network connection is a satellite link connected via a local WiFi link. I have not experienced any problems using this for emails, web browsing and even (occasionally) video streaming.
Thank you again for your support.

Thank you, I will follow this in future. I did lots of reading but not this particular piece.

OMG. Paste the results of ping blynk-cloud.com
My results from your sketch with a WeMos D1 Mini:

Timer Event triggered
sending millis/1000   to Blynk V0 value=205 Blynk connection flag=1 millis=1205163
sending millis/1000+1 to Blynk V1 value=206 Blynk connection flag=1 millis=1205167
sending millis/1000+2 to Blynk V2 value=207 Blynk connection flag=1 millis=1205175
sending millis/1000+3 to Blynk V3 value=208 Blynk connection flag=1 millis=1205182
Not Connected counts = 0 0 0 0 cycles = 40

Another common problem experienced by noob Blynkers is not understanding how the data in the app is obtained. For Value display widgets the default is for data to be received with a READING RATE of 1 sec. So without any lines of code in a basic Blynk sketch sensor data will be read by Blynk and presented in the app.

However as soon as you use virtualWrite() you need to change the READING RATE to PUSH i.e. your MCU / sketch is pushing the data to the app (via a server). The PUSH_DATA example does include reference to setting the widget to PUSH. Do you have your 4 Value display widgets set as PUSH or the default 1 sec?

1 Like

Yes I have ll my display widgets set to PUSH.
I will post results of pings shortly. I find them interesting, if not very conclusive so far.
Keith

Here is my updated code including Pings of Google (in setup only) and blynk-cloud.com (in setup and for each connection failure).
When there is a connection failure just prior to sending data, I do a Ping, and if that is successful I do a Blynk.connect() based on the logic that if the ping worked, there is no reason why the connection should not. Results don’t quite bear that out from casual observation. I will add some data collection to quantify the frequency of the various cases.
Here is the latest code:

// modified by farmerkeith 22 July 2017
/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************

  This example shows how value can be pushed from Arduino to
  the Blynk App.

  NOTE:
  BlynkTimer provides SimpleTimer functionality:
    http://playground.arduino.cc/Code/SimpleTimer

  App project setup:
    Value Display widget attached to Virtual Pin V5
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <ESP8266Ping.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "8xxxxxxxxxxxxxxxxxxxxxxxxx";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "tanderra";
char pass[] = "xxxxxxxxxx";

long cycles = 0;
long notConnectedCount0 =0 ;
long notConnectedCount1 =0 ;
long notConnectedCount2 =0 ;
long notConnectedCount3 =0 ;

BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  cycles ++;
  Serial.println ("\nTimer Event triggered");
// --------------------------
  Serial.print ("sending millis/1000     to Blynk V0 value=");
  Serial.print (millis()/1000%1000);
  byte yesConnected = Blynk.connected();
  Serial.print (" Blynk connection flag=");
  Serial.print (yesConnected);
  Serial.print (" millis=");
  Serial.println (millis());
  if (yesConnected == 0){
    notConnectedCount0 ++;
    handleNoConnection();
  }
  Blynk.virtualWrite(V0, millis() / 1000 %1000);
// --------------------------
  Serial.print ("sending millis/1000+1   to Blynk V1 value=");
  Serial.print ((millis()/1000+1)%1000);
  yesConnected = Blynk.connected();
  Serial.print (" Blynk connection flag=");
  Serial.print (yesConnected);
  Serial.print (" millis=");
  Serial.println (millis());
  if (yesConnected == 0){
    notConnectedCount1 ++;
    handleNoConnection();
  }
  Blynk.virtualWrite(V1, (millis() / 1000+1) %1000);
// --------------------------
  Serial.print ("sending millis/1000+2   to Blynk V2 value=");
  Serial.print ((millis()/1000+2)%1000);
  yesConnected = Blynk.connected();
  Serial.print (" Blynk connection flag=");
  Serial.print (yesConnected);
  Serial.print (" millis=");
  Serial.println (millis());
  if (yesConnected == 0){
    notConnectedCount2 ++;
    handleNoConnection();
  }
  Blynk.virtualWrite(V2, (millis() / 1000+2) %1000);
// --------------------------
  Serial.print ("sending millis/1000+3   to Blynk V3 value=");
  Serial.print ((millis()/1000+3)%1000);
  yesConnected = Blynk.connected();
  Serial.print (" Blynk connection flag=");
  Serial.print (yesConnected);
  Serial.print (" millis=");
  Serial.println (millis());
  if (yesConnected == 0){
    notConnectedCount3 ++;
    handleNoConnection();
  }
  Blynk.virtualWrite(V3, (millis() / 1000+3) %1000);
// --------------------------

  Serial.print ("Not Connected counts = ");
  Serial.print (notConnectedCount0);
  Serial.print (' ');
  Serial.print (notConnectedCount1);
  Serial.print (' ');
  Serial.print (notConnectedCount2);
  Serial.print (' ');
  Serial.print (notConnectedCount3);
  Serial.print (" cycles = ");
  Serial.println (cycles);

}

void setup()
{
  // Debug console
  Serial.begin(9600);
  delay (10);

  Serial.println();
  Serial.println("BlynkPushdataV5");
  Serial.println("Connecting to WiFi");
  WiFi.begin(ssid, pass);
  while (WiFi.status() != WL_CONNECTED) {
    delay(200);
    Serial.print(".");
  }
  Serial.println();
  Serial.print("WiFi connected with ip ");  
  Serial.println(WiFi.localIP());
  pingGoogle() ;
  pingBlynk() ;
  WiFi.disconnect();
  
  long beginMillis = millis();
  Serial.print ("\nBlynk.begin has started at "); // added by KH
  Serial.println (beginMillis); // added by KH
  
  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
  long beginDuration = millis()-beginMillis;
  Serial.print ("\nBlynk.begin has returned after "); // added by KH
  Serial.print (beginDuration); // added by KH
  Serial.print (" ms. millis="); // added by KH
  Serial.println (millis()); // added by KH

  // Setup a function to be called every 30 seconds
  timer.setInterval(30000L, myTimerEvent); // changed to 30s, KH
} // end of setup()

void loop()
{
  Blynk.run();
  timer.run(); // Initiates BlynkTimer

} // end of  loop()


void pingGoogle() {
  
// IPAddress ip (192, 168, 0, 1); // The remote ip to ping
// bool ret = Ping.ping(ip);
// ret will be true if the remote responded to pings, false if not reachable.
// The library supports hostname too, just pass a string instead of the ip address:
// Additionally, the function accept a second integer parameter count 
// that specify how many pings has to be sent:
// bool ret = Ping.ping(ip_or_host, 10);
// After Ping.ping() has been called, the average response time (in milliseconds) 
// can be retrieved with

  for (byte i = 0; i<10; i++) {
    bool ret = Ping.ping("www.google.com");
    int avg_time_ms = Ping.averageTime();
    Serial.print ("Ping Google done. Result=");
      if(ret){
      Serial.print ("Success"); 
      Serial.print (" Response time =");
      Serial.println (avg_time_ms);
      break;
      } else {
        Serial.println ("Fail");
      }
  } // end of for loop
} // end of pingGoogle()
  
bool pingBlynk() {
  bool ret = Ping.ping("blynk-cloud.com");
  int avg_time_ms = Ping.averageTime();
  Serial.print ("Ping Blynk done. Result=");
  if(ret){
    Serial.print ("Success"); 
    Serial.print (" Response time =");
    Serial.println (avg_time_ms);
  } else {
    Serial.println ("Fail");
  }
  return ret;
} // end of pingBlynk()

void handleNoConnection() {
  bool ret = pingBlynk() ;
  if (ret==1) { // try to reconnect if Ping is successful
    bool yesConnected = Blynk.connect();
    Serial.print (" Blynk connect retry, result flag=");
    Serial.print (yesConnected);
    Serial.print (" millis=");
    Serial.println (millis());
  }
} // end of void handleNoConnection()

Here is a sample of the output when a connection failure is encountered. Iin this case the logic works well, Ping success is followed by Connection success.

Timer Event triggered
sending millis/1000     to Blynk V0 value=916 Blynk connection flag=0 millis=916621
Ping Blynk done. Result=Fail
sending millis/1000+1   to Blynk V1 value=926 Blynk connection flag=0 millis=925771
Ping Blynk done. Result=Success Response time =541
[931624] Connecting to blynk-cloud.com:8442
[932811] Ready (ping: 931ms).
 Blynk connect retry, result flag=1 millis=932955
sending millis/1000+2   to Blynk V2 value=935 Blynk connection flag=1 millis=933112
sending millis/1000+3   to Blynk V3 value=936 Blynk connection flag=1 millis=933262
Not Connected counts = 4 5 4 3 cycles = 29

Timer Event triggered
sending millis/1000     to Blynk V0 value=943 Blynk connection flag=1 millis=943320
sending millis/1000+1   to Blynk V1 value=944 Blynk connection flag=1 millis=943496
sending millis/1000+2   to Blynk V2 value=945 Blynk connection flag=1 millis=943638
sending millis/1000+3   to Blynk V3 value=946 Blynk connection flag=1 millis=943795
Not Connected counts = 4 5 4 3 cycles = 30

Here is another case, not so good for the logic. For the V2 transmission, the initial connection flag is 0 (no connections); the Ping succeeds, but then the reconnect attempt also fails.

Timer Event triggered
sending millis/1000     to Blynk V0 value=63 Blynk connection flag=1 millis=1063320
sending millis/1000+1   to Blynk V1 value=69 Blynk connection flag=0 millis=1068322
Ping Blynk done. Result=Fail
sending millis/1000+2   to Blynk V2 value=76 Blynk connection flag=0 millis=1074437
Ping Blynk done. Result=Success Response time =341
[1081461] Connecting to blynk-cloud.com:8442
 Blynk connect retry, result flag=0 millis=1088610
sending millis/1000+3   to Blynk V3 value=91 Blynk connection flag=0 millis=1088611
Ping Blynk done. Result=Fail
Not Connected counts = 5 6 5 4 cycles = 34
[1095910] Connecting to blynk-cloud.com:8442

thank you for your continued attention.
If you have any suggestions for a better way to deal with this, I would be very grateful.

I’m looking for general ping stats from your console, not via Blynk.

I can open a terminal emulator and put in the ping command. I get

ping blynk-cloud.com 
PING blynk-cloud.com (45.55.96.146) 56(84) bytes of data.
64 bytes from 45.55.96.146 (45.55.96.146): icmp_seq=1 ttl=50 time=862 ms
64 bytes from 45.55.96.146 (45.55.96.146): icmp_seq=2 ttl=50 time=846 ms
64 bytes from 45.55.96.146 (45.55.96.146): icmp_seq=3 ttl=50 time=846 ms
64 bytes from 45.55.96.146 (45.55.96.146): icmp_seq=4 ttl=50 time=876 ms
64 bytes from 45.55.96.146 (45.55.96.146): icmp_seq=5 ttl=50 time=847 ms
64 bytes from 45.55.96.146 (45.55.96.146): icmp_seq=6 ttl=50 time=827 ms
64 bytes from 45.55.96.146 (45.55.96.146): icmp_seq=7 ttl=50 time=818 ms
64 bytes from 45.55.96.146 (45.55.96.146): icmp_seq=8 ttl=50 time=810 ms
64 bytes from 45.55.96.146 (45.55.96.146): icmp_seq=9 ttl=50 time=810 ms
64 bytes from 45.55.96.146 (45.55.96.146): icmp_seq=10 ttl=50 time=807 ms
64 bytes from 45.55.96.146 (45.55.96.146): icmp_seq=11 ttl=50 time=815 ms
64 bytes from 45.55.96.146 (45.55.96.146): icmp_seq=12 ttl=50 time=815 ms
64 bytes from 45.55.96.146 (45.55.96.146): icmp_seq=13 ttl=50 time=828 ms
64 bytes from 45.55.96.146 (45.55.96.146): icmp_seq=14 ttl=50 time=1267 ms
64 bytes from 45.55.96.146 (45.55.96.146): icmp_seq=15 ttl=50 time=809 ms
64 bytes from 45.55.96.146 (45.55.96.146): icmp_seq=16 ttl=50 time=810 ms
64 bytes from 45.55.96.146 (45.55.96.146): icmp_seq=17 ttl=50 time=809 ms
64 bytes from 45.55.96.146 (45.55.96.146): icmp_seq=18 ttl=50 time=889 ms
.
.
.

It seems to go on forever. I this what you wanted to see?

Yes. The time for my pings are around 65ms compared with yours of around 830ms (even as long as 1267ms).
It could be based on your location in the world in relation to your “local” Blynk server but more likely to be your satellite link.

Go back to your initial sketch and provide the results when you have upgraded your library to 0.4.8.

1 Like

Yeap. Seems like you really have a bad connection with the blynk cloud. Where are you located physically (country infor would be enough :slight_smile: )?

1 Like

Ahh. I missed that. In that case the best option would be to use Local Bylnk server as proposed by @Costas.

OK I will look into the library upgrade, probably tomorrow.
Yes I am sure the satellite link is mainly responsible for the long loop times, since it is a geostationary satellite, for which the basic propagation loop is about 600 ms.
The limited bit rate on the link will also add a bit more delay.
In a few days time I will be able to test with a terrestrial data network, which may provide a good contrast.
if the library upgrade deals with this loop delay, that would be great. In the past there were a lot of protocols that did not deal well with satellite links (eg fax) but I thought the modern era data networks had that all ticked off.
Thanks again.

@Dmitriy I wasn’t actually suggesting a local server but the geo-dns server for @farmerkeith but yes a local server would certainly help.

@farmerkeith you should still be able to use your satellite system with Blynk but code around the satellite limitations.

FYI I am in Australia, on a country property where the only internet service I can get is via satellite (our National Broadband Network).
My locality is Rock Forest, if you would like to look it up.

@farmerkeith Australia? Hm… Could you please ping also 188.166.206.43 IP and post results here?