cotestatnt / AsyncTelegram2

Powerful, flexible and secure Arduino Telegram BOT library. Hardware independent, it can be used with any MCU capable of handling an SSL connection.
MIT License
83 stars 25 forks source link

AsyncTelegram2 hangs the uC, when "unable to connect to server" #118

Open miguelfernando55 opened 11 months ago

miguelfernando55 commented 11 months ago

When it is not connected to the server, the uC hangs. It also should be async.

cotestatnt commented 11 months ago

Hi @miguelfernando55 . Which microcontroller is it?

miguelfernando55 commented 11 months ago

esp32-s2-saola. Here what it is happenning image When it is unable, it delays the normal functionality of the rest of the system. As you may check in the image, I have an interval to send new info. When it happens "unable ... ", it is much longer

cotestatnt commented 11 months ago

Thanks for your feedback, I will try to check after 20th August because I am going on vacation from next weekend

miguelfernando55 commented 11 months ago

Ok. Nice holidays. Hope you may upgrade the functionality.

miguelfernando55 commented 11 months ago

Is it able to use a flag that warns when the "unable to connect to server" happens? Or does bool checkConnection(); is enough?

It would be good if we could question the telegram server if he is able to start a connection. Before really starting one.

cotestatnt commented 10 months ago

Hi @miguelfernando55 Regarding your issue, it is not clear to me if the failed connection to the Telegram server happens even if the esp32 is correctly connected to the internet.

If you don't have an active internet connection, you should avoid calling the getNewMessage() method (and more generally the other library methods) because an attempt to connect to the server will still be made and this step is blocking (you can set a timeout eventually).

Checking the internet connection cannot be "internal" to the library because it is strictly linked to the hardware interface (WiFi, Ethernet, GPRS etctec).

miguelfernando55 commented 10 months ago

You are right. The esp32 may be connected to the router, but the router lost internet connection. It was because of this situation that the "unable to ...." happenned. I am blocking and not able to design a way to avoid this situation.

miguelfernando55 commented 10 months ago

Are you able to provide me a status variable when the connection is hanging?