Blynk.connect (timeout) - the timeout does not match the set

Blynk.connect(timeout) does not work correctly when the Internet connection is broken - the real timeout is always approximately 18 seconds.
Blynk.connect(timeout) works correctly - real timeout is set - when the wifi connection is broken.
But with a good Wi-Fi connection, but a broken Internet connection, the timeout does not match the setting, my measurements always show about 18 seconds, although the setting is 3 seconds.


It is very important for me that when the Internet connection is broken, my controller is not blocked, but continues to perform important functions, except for Blynk.
In fact, it turns out that if the Wi-Fi connection is working, but there is no Internet, then the controller is blocked for 18 seconds., every time I try to connect to the server…

If you want all the code, here it is:

#define BLYNK_TEMPLATE_ID           "--"
#define BLYNK_DEVICE_NAME           "--"
#define BLYNK_AUTH_TOKEN            "--"

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

BlynkTimer timer; // timer for Blynk Connection Function

bool WiFiok = false; // connection wifi
bool BlynkCon = false; // connection Blynk

char auth[] = BLYNK_AUTH_TOKEN;

char ssid[] = "--";
char pass[] = "--";

void setup()
{
  Serial.begin(9600);

  WiFi.begin(ssid, pass);
  Blynk.config(auth); 
  timer.setInterval(35 * 1000, BlynkConFunction);// connection to the server - period 35 sec
}


void loop()
{
  timer.run();
  
  if (BlynkCon) {
    Blynk.run();
    }
}



void BlynkConFunction() // Blynk Connection Function
{
      if (WiFi.status() == WL_CONNECTED)  {
      WiFiok = true; 
      Serial.println("Wifi_OK");
      if (!Blynk.connected()) {
          Serial.println("Connecting_to_Blynk...");
          BlynkCon = Blynk.connect(5000); 
          Serial.println("Connecting_attempt_ended.");
          if (BlynkCon) {
            Serial.println("Blynk_connected");
          }
          else {
            Serial.println("Blynk_FAIL");
            }
      }
      else {
          Serial.println("Blynk_OK");
      }
  }
    else  {
      WiFiok = false;
      BlynkCon = false;
      Serial.println("Wifi_FAIL");
    }
}

This is a follow-up from this discussion…

As I’ve stated in that topic, I don’t believe that this is a bug, and my test code - which eliminates all of your unnecessary flags - appears to demonstrate this.

It’s difficult to have a sensible conversation across multiple topics, so I’m going to close this topic.
The topic will still be visible, and Blynk staff will still be able to comment on it, as they have admin rights to the forum, but it will prevent other forum members from commenting here.
If other forum members do want to comment then they can do this on the original topic linked above.

If the discussion in the original topic shines new light on this issue then I’m happy to come back and re-open this topic.

UPDATE - problem solved by updating the ESP32 core.

Pete.

1 Like