Bynk randomly drops connection

Hello,

I have a problem that Blynk periodically time outs at heartbeat (drops connection).

  • Hardware: Own PCB with ESP-12E
  • Communication: WiFi (RSSI ~ -50 dbm)
  • Blynk server [139.59.206.133] port [80]
  • My smartphone is Asus ZC553KL (Android 7).

As people suggested here on forums, I’ve checked power supply. I’ve added terminal commands, to query device’s uptime and WiFi reconnection times.

There is nothing more than BLYNK_WRITE default handler in my app.

My loop function looks like this:

void loop()
{
Blynk.run();
ArduinoOTA.handle();
delay(1);
}

I’m afraid people will ask for the full code in order to help.

Even with blank sketch same things happen:

Try a real blank sketch without all the OTA and header file stuff.

Didn’t help, same.

Bad power, bad internet, bad ESP, bad neighbours (really), etc.

Let us know when you track down the issue.

I’ve disabled MDNS in ArduinoOTA and added:

client->flush(1000)

in ‘write’ function in BlynkArduinoClient.h.

Now connection handler will wait up to 1 second in flush() to ensure everything was sent. More elegant way would be to wait BLYNK_TIMEOUT_MS instead of hardcoded 1000ms.

However, it looks like a bug in connection implementation in Blynk library. It will cause frequent connection drops, when there is some latency on network, even much smaller than BLYNK_TIMEOUT_MS set in BlynkConfig.h

Anyway, I’m very disappointed at Blynk library code quality. It looks very amateur. They are mixing C-like structural programming with C++ features, placing function bodies inside header files, multiple ‘fix’ macro are flying around (e.g. YIELD_FIX()). Generally a bunch of bad programming pratices.

Sometimes I think it would be nice to write Blynk client at my own, to match my requirements and provide more reliability.

Really painful sometimes to use in object oriented project or even not single file project.

Libraries are open source and they often state that contributions would be welcome. Use their GitHub for such - GitHub - blynkkk/blynk-library: Blynk library for IoT boards. Works with Arduino, ESP32, ESP8266, Raspberry Pi, Particle, ARM Mbed, etc.

1 Like