blynkkk / blynk-library

Blynk library for IoT boards. Works with Arduino, ESP32, ESP8266, Raspberry Pi, Particle, ARM Mbed, etc.
https://blynk.io
MIT License
3.83k stars 1.39k forks source link

Login timeout if memory usage is above 71% #381

Closed mbence closed 6 years ago

mbence commented 6 years ago

Blynk library version: [0.4.10] Blynk local server version: [0.28.9] IDE: [Arduino] IDE version: [1.8.5] Board type: [Arduino Nano] Additional modules: [DS3231]

Scenario, steps to reproduce

I would like to get the time from the local server with Blynk.sendInternal("rtc", "sync").

Expected Result

BLYNK_WRITE(InternalPinRTC) callback is called with current time.

Actual Result

Blynk hangs in an endless loop of Ready (ping: 104ms). - Login timeout at Blynk.begin().

Server logs (blynk.log) shows this strange message:

Discarded inbound message PooledUnsafeDirectByteBuf(ridx: 0, widx: 40, cap: 40) that reached at the tail of the pipeline. Please check your pipeline configuration.

Even stranger is, that the code never gets to the sendInternal command. It just hangs at Blynk.begin(). But if I remove this one line (Blynk.sendInternal("rtc", "sync")), the rest works perfectly.

Edit: Debug serial output:

[12290] Connected to WiFi
[12436] <[02|00|01|00] b4d79f227f314b6fa3e2b6df8d173b9e
[12641] >[00|00|01|00|C8]
[12641] Ready (ping: 104ms).
[12642] <[11|00|02|00]gver[00]0.4.10[00]h-beat[00]10[00]buff-in[00]256[00]de
[17742] Cmd error
[22767] Cmd skipped:16
[22767] Login timeout

Is this a bug, or am I doing something wrong?

Edit 2: I'm pretty sure now, that it is a memory issue, and not strictly correlated with the sendInternal command. Check out this gist: https://gist.github.com/mbence/588d189a30323fa8c28b3890418c9621 I created a very simple example with a Nano and an esp8266 as a modem, that is working correctly. Until the memory consumption reaches 71%, when the process stucks at login.

Thanks for reading all this, and I hope this info helps uncovering the problem!

vshymanskyy commented 6 years ago

This is not a bug, you just went out of resources. You can try posting at http://community.blynk.cc/ Maybe someone from the community will help optimizing it.