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
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
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.