cotestatnt / AsyncTelegram

Async Arduino Telegram BOT Library for ESP8266 and ESP32

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

loss of sending multiple messages

lucagir opened this issue · comments

I am using your scratch and it works very well, I only found 2 small problems:

  1. sometimes it loses the connection and is no longer reachable by telegram. Neither with incoming and outgoing messages.
  2. if I send more messages they are lost. I have seen that if I already send 2 messages the second does not arrive. For this problem I have built a FIFO queue at home, and I use it as a layer in the "sendMessage" method to insert the messages and in the "httpPostTask" to do the get of the messages and subsequent sending.

Do you think the change I inserted in point 2 can cause a loss of connection described in point 1?

+1
ESP32 really loss a lot of messages if we trying to send it by external trigger (for example, send message when pin triggered)
If use ESP32 only for reply to incoming messages, it working good :/

ESP8266 does not affected

Sorry for big late response, but in these days my free time has been dedicated to the development of version 2.

As for the problem in question, I suppose that somehow it is due to the fact that with the esp32, sending of commands to the server takes place in a parallel task and therefore the requests are "overlapped" with periodically getUpdates() request.
Indeed, in the new version I have removed this mechanism leaving the users free to choice if use or not the task management (but on the sketch side like I've done in ESP32-CAM.ino for example).

If you want try to switch, I've created a distinct repo for the reason explained within readme,
I'm testing it since days with very good results. Now i'm testing a sketch for sending a message every 10s like this.
Actually it fails sometimes (less than 1%) when connection was closed from server side while sending message, but i'm sure this can be avoided easily for example checking for new messages just before.

if(millis() - tMessage > 10000){  
  tMessage = millis();  
  time_t now = time(nullptr);  
  struct tm time = *localtime(&now);
  char buffer[128];
  static int count = 0;
  snprintf(buffer, 256, "%d - %02d:%02d:%02d\n",  count++, time.tm_hour,  time.tm_min, time.tm_sec);
  Serial.print(buffer);
}

BTW if we disable multicore http-client (use esp32 with "ESP8266 ifdefs") then loss of messages bug is gone.

I suggest adding the option to disable the multi-core client and use blocking functions if the user wants to get stable message delivery