Blynk fail to recconect to the server after some time

hello ,
This is my code:
bool result = Blynk.connected();
Serial.println(“BLYNK connected”);
Serial.println(“BLYNK connecting”);

Blynk fails to reconnect to the server.I think blynk.connect command is not working properly

better use @Gunner example

Blynk.connected(); giving wrong result even if it is not connected to the internet that is why it’s not trying to make a connection to the blynk server

Sir , I am using esp32 board

You code looks like a random snippet that doesn’t do us any real good. Where are you running this code, what else is happening in the sketch… ands so on.

It works perfectly for hundreds/thousands of other users… but only if utilised properly in code.

Look thoroughly through the examples already given… the basic concepts work regardless of ESP8266, ESP32, Arduino, WiFi, GSM, Ethernet, Serial, etc.

  • Do stuff
  • Check if connected, if so do stuff
  • If not, keep doing stuff but start attempting reconnection at pre selected intervals
  • Repeat
1 Like

I have used FREERTOS and created task base system. Following program is one of the task where it maintains connection between esp32 and blynk server.This logic works fine when there is no problem with internet connection. If the device is not connected to the server, it will make a connection after 30 sec. I have given the authentication code in setup function using Blynk.config(auth, server, port); . Sometimes it works sometime its not. It is only showing "Blynk connecting " message on the screen but its not actually trying to reconnect.

void blynk_con(void * pvParameters)
      if(WiFi.status()== WL_CONNECTED&&flagw==1)
         bool result =  Blynk.connected();
         Serial.println("BLYNK connected"); 
            Serial.println("BLYNK connecting");   

Don’t forget to format posted code…