You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use this bot through mobile 3G connection and I found that it eats a lot of mobile traffic.
I investigated this misadvantage and found the solution.
Telegram provides POLL mode of the connection. We should use special option in the query to say how long we can wait for the data. In current release bot sends update query every 1 second and immediately gets back empty message. To solve it, I modified the code of bot:
In header "UniversalTelegramBot.h" add new definition "#define POLL_TIME_WAIT 60 // seconds"
Higher value is better for traffic economy
In source "UniversalTelegramBot.cpp" add some modifications:
function UniversalTelegramBot::sendGetToTelegram(String command):
main loop:
while (millis() - now < (POLL_TIME_WAIT*1000+1000)) {....}
function UniversalTelegramBot::getUpdates(long offset)
String command = "bot"+_token+"/getUpdates?offset="+String(offset)+"&limit="+String(HANDLE_MESSAGES)+"&timeout="+string(POLL_TIME_WAIT);
I successfully tested these code improvements.
Thanks for your attention.
P.S. I'm too lazy to make new fork.
P.P.S. Telegram answers empty after 50 seconds wait. It means, that maximum value for POLL_TIME_WAIT is 50 secs
The text was updated successfully, but these errors were encountered:
IMHO default value for POLL should be 5-20 seconds.
IMHO ~1Gb of spurious traffic every month for each ESP where this bot installed is very expensive for the World. Think about green trees and nature pollution.
It changes the default behavior of the library if any poll is included,
anyone who upgrades from v1 to v1.1 shouldn't have behaviours changed if it
can be helped.
On 17 Oct 2017 20:20, "denzen84" ***@***.***> wrote:
IMHO default value for POLL should be 5-20 seconds.
IMHO ~1Gb of spurious traffic every month for each ESP where this bot
installed is very expensive for the World. Think about green trees and
nature pollution.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#53 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABfXwu9KaMP8ktuNS9DUMyQFanfi9U_mks5stP4UgaJpZM4P2pmv>
.
Hi,
I use this bot through mobile 3G connection and I found that it eats a lot of mobile traffic.
I investigated this misadvantage and found the solution.
Telegram provides POLL mode of the connection. We should use special option in the query to say how long we can wait for the data. In current release bot sends update query every 1 second and immediately gets back empty message. To solve it, I modified the code of bot:
In header "UniversalTelegramBot.h" add new definition "#define POLL_TIME_WAIT 60 // seconds"
Higher value is better for traffic economy
In source "UniversalTelegramBot.cpp" add some modifications:
function UniversalTelegramBot::sendGetToTelegram(String command):
main loop:
while (millis() - now < (POLL_TIME_WAIT*1000+1000)) {....}
function UniversalTelegramBot::getUpdates(long offset)
String command = "bot"+_token+"/getUpdates?offset="+String(offset)+"&limit="+String(HANDLE_MESSAGES)+"&timeout="+string(POLL_TIME_WAIT);
I successfully tested these code improvements.
Thanks for your attention.
P.S. I'm too lazy to make new fork.
P.P.S. Telegram answers empty after 50 seconds wait. It means, that maximum value for POLL_TIME_WAIT is 50 secs
The text was updated successfully, but these errors were encountered: