Closed rogercorrea closed 7 years ago
MakeRequestAsync
expect only request
object in parameters. What Timeout
you are speaking about?
My code to GetUpdates:
updates = bot.MakeRequestAsync(new GetUpdates() { Offset = offset, Timeout = 120 }).Result;
Sorry! It correct is timeout in the GetUpdates, sure? But I set 120 seconds and don't work for me.
This timeout is not about your internet connection. It's for Telegram server - interval for long-polling where there is no messages available, see docs
Ok. My code generates one exception for the long pool. Haven't relation with the timeout in the GetUpdates?
Request failed (status code 409): Conflict: terminated by other long poll or webhook
I'm using a web proxy. It is very important.
My code example:
var me = bot.MakeRequestAsync(new GetMe()).Result;
string msg = string.Empty; //Resposta do robô para o usuário
long chatId = 0; //Id do usuário que receberá a mensagem
long offset = 0;
Update[] updates = null;
while (true)
{
try
{
updates = bot.MakeRequestAsync(new GetUpdates() { Offset = offset, Timeout = 120 }).Result;
if (updates != null)
{
//Laço que trata cada nova requisição recebida
foreach (var update in updates)
{
offset = update.UpdateId + 1;`
This code is returned by Telegram server, I'm not from Telegram team and can only guess...
Do you have webhook installed/registered?
Or may be you call GetUpdates
periodically with interval less than 120 seconds - may be connection failed, but proxy still waits for response from Telegram server...
But he work in the first time and not more. And for more that 120 seconds. I can trying for the long time and only work if I restart the Windows service. I don't understand because it occur.
My first line included GetMe:
var me = bot.MakeRequestAsync(new GetMe()).Result;
It's too many "extra" factors - service, proxy, etc.
Try on sample project (add Timeout to GetUpdates) and try with good internet and without proxies. Then add "bad factors" back one by one to find where is the problem.
Closing as no answer. Please reopen if you are experiencing same problems with test project.
Please,
I am trying use the Timeout property in the MakeRequestAsync to call GetUpdates but don't work. And I went to see the source code and not finded the property in the function.
She is used? My internet is unstable and I receive errors in all the time. Thanks!