ESP32 secure connection failed after a while

Can your Pi see the Internet?
Can your mobile connect to your local Blynk server?
Can you ping your local server from other devices on your network?
If you run an IP scanner utility from a PC on your network does it show all of the devices you expect?
If you run a port scanner against your local server what does it show?

Pete.

My DietPi (X86) can see the internet
I can mobile connect to my local Blynk server via its URL and Port number (https://XXX.com:9443)
I can ping my local server from other devices in my network.
Used the “Advanced IP Scanner” and can see all devices that I expect (including the ESP8266).
I see all important ports.

I got the problem: the letsencrypt certificate expired :D…

Thanks for the help guys!

I will contunie tomorrow with my tests.

OK, as for your “ESP32 connection reliability” issue… I can confirm with two different devices/projects, that Blynk connectivity WILL eventually drop… but depending on how one codes their routines, the rest of the device will keep on running.

Common factors in both devices:

  • Using standard Blynk library… NOT SSL.

  • Using Blynk.config() NOT Blynk.begin()

  • NO Blynk.run() in the void loop - something that seems to be a specific ability with ESP32 Library, and one that I cannot clearly recall if has been mentioned before in this forum.

  • Using other, non Blynk code, to display device functionality (LCD, OLED, Nextion, etc.)

  • Both devices do use WiFi for other applications, notably OTA, but also time sync and 3rd party applications (Virtuino on one device)

  • So far, Blynk Server/App functionality will NOT reconnect without physically rebooting the device.

Uncommon factors…

  • One device used Static IP, setup via code, the other used DHCP.

  • One device also had Virtuino code embedded… and while it will also lose connectivity over time, it will reconnect upon restarting the App (restarting the device is NOT required)… but in Virtuino’s case, it’s “server” is coded into the device.

  • One device had a rudimentary “reset via code” function if losing Blynk connection. It is possible that reset was working, as it’s last shown uptime was 3 minutes, ending sometime this morning…

image

Whereas the other device, without any such reset but also much less Blynk activity, didn’t fail until after 46371 seconds (about 772.8 minutes or 12.8 hours)… also this morning, but at a different time…

image

Both devices were originally last flashed and started around the same time last evening.

Basically, I suspect something in the ESP’s WiFi side of things… and something that is influenced by Blynk’s need for a constant connection.

1 Like

Thanks for your answer Gunner.

I always welcome your positive and constructive posts :slight_smile: (also in other threads).

Not using SSL is no option for me.
The device will be used remotely on a mobile hotspot and sending data between the device unencrypted is not a good solution.
I will have a look at the Blynk.config() NOT Blynk.begin() thing and will defenitly drop the Blynk.run() also because of speed reasons.

I have tested back and forth and the device is now running a whole day and reconnects after that.

I think the disconnection is because of my local wifi and/or the remote mobile wifi gets a reconnect forces by the internet provider, as it is always around 6am (6:00 in the morning) ±2min.

I always use a serial connection to debug and show important informations.

The program always still worked in background (also with lost blynk sync).

I never had any wifi signal issues (always at least at 60%… once I had 102% ?? )
calculated with this:

wifiSignal = map(WiFi.RSSI(), -105, -40, 0, 100);

I still have Blynk.begin() in setup.

I still have Blynk.run() in loop.
This makes my program a lot slower, but as it is a remote device with mobile connection (so I have not unlimited data volumes to download/upload) I only send data when needed.
It could happen that no blynk function is called during a loop, which cause a lost connection to blynk server and will not remain.

Possible solution for this would be to call Blynk.run() only after a certain time has passed and not every loop call. But I have not tested it.

What finally solved the issue was to put a small delay into the loop.
As I read about power consumption I saw that no real sleep functionality is supported for ESP32 on Arduino IDE.
But they included an “automatic” light sleep during delay().
So I added a short delay(1) (just 1ms) and that already solved my issues.

Conclusion is, that it might have been an overheating issue (ESP32 got pretty warm… not hot, but pretty warm) and now its noticeable cooler.