Gianbacchio / ESP8266-TelegramBot

Telegram Bot Library for ESP8266 on Arduino IDE
GNU General Public License v2.0
187 stars 71 forks source link

hang when I disconnect internet #9

Open fubax opened 7 years ago

fubax commented 7 years ago

Hi. Excuse me for my English. I’m using flashled bot and I’m trying to build a device that has high reliability. Sometimes When I deliberately disconnect Internet connection ,my ESP’s hangs and after about 13 minutes it recover again and send failed to update to serial monitor.if I re-establish Internet connection between that 13 minutes and send a new command to BOT ,ESP can not run it and I will wait to that times be elapsed But sometimes it doesn't hangs and after lower than 2 seconds I see failed to update in my serial monitor. Is there any defined timeout for waiting for server reply?and how I can decrease it to lower than 1 minutes? I hope I could explain what I mean. Thank you in advance.

Gianbacchio commented 7 years ago

Hello, sorry my late reply.

It is not really clear to me this 13 minutes delay in reconnection. Esp, not really because of my library, try to reconnect when detects that the router has gone. The reaction time is quite fast, my experience is in terms of some seconds.

It is true that some routers take a long time to connect to esp. in the case, it could take also many minutes. May be you are in this situation.

Recently, some other users of the library suggested me to modify the connection procedure in setup() in this way:

instead of:

while (WiFi.begin(ssid, pass) != WL_CONNECTED) { Serial.print("."); delay(500); }

use:

WiFi.begin(ssid, pass); while ( WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(500); }

tell me if it solves the issue.

May be you have seen that the varialble

int Bot_mtbs = 1000; //mean time between scan messages

(it defines the time between each control).

The time out in server reply, is part of the library you can find it in the function

String TelegramBOT::connectToTelegram(String command)

...

while (millis()-now<1500) { while (client.available()) { char c = client.read(); //Serial.write(c); if (ch_count<700) { mess=mess+c; ch_count++; }

at the moment, it is set into 1500 msecs

if it fails, returns: "failed to update"

best regards Giancarlo

2016-11-27 10:50 GMT+01:00 fubax notifications@github.com:

Hi. Excuse me for my English. I’m using flashled bot and I’m trying to build a device that has high reliability. Sometimes When I deliberately disconnect Internet connection ,my ESP’s hangs and after about 13 minutes it recover again and send failed to update to serial monitor.if I re-establish Internet connection between that 13 minutes and send a new command to BOT ,ESP can not run it and I will wait to that times be elapsed But sometimes it doesn't hangs and after lower than 2 seconds I see failed to update in my serial monitor. Is there any defined timeout for waiting for server reply?and how I can decrease it to lower than 1 minutes? I hope I could explain what I mean. Thank you in advance.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Gianbacchio/ESP8266-TelegramBot/issues/9, or mute the thread https://github.com/notifications/unsubscribe-auth/ALU0ty8uhACP0uGpTyKiucc4pO4xEOXEks5rCVJRgaJpZM4K9G2V .

-- Giancarlo Bacchio mob. +39 3313136813 skype: giancarlo_bacchio

fubax commented 7 years ago

Happy new year and thanks for helping me. Excuse me but my problem is not WiFi connect delay. Sometimes when I randomly disconnecting internet connection I see : GET Update Messages and after about 13 minutes failed to update And if I reconnect the internet connection in between that time, the ESP does not recover from that's fault state and I will wait about 13 minutes to be elapsed to ESP attempt again to connect to server