简体   繁体   English

使用带有 C# 的电报机器人出现错误“请求超时”?

[英]Getting error “Request timed out” using telegram bot with c#?

I am go send 10 images with caption on the telegram bot using c#.but just go there 2 or 3 image and getting error like this " Request timed out " from the api " SendPhotoAsync ".i don't know where is mistake.我要使用 c# 在电报机器人上发送 10 张带有标题的图像。但是只要去那里 2 或 3 张图像并从 api“ SendPhotoAsync ”得到这样的错误“请求超时”。我不知道错误在哪里。 i am run this in my local pc.我在我的本地电脑上运行这个。 and my pc is fully under in network so why i am getting this error any one know please let me.并且我的电脑完全在网络中,所以为什么我会收到此错误,任何人都知道请告诉我。

This is my code=>这是我的代码=>

public async Task SendCasesOnTelegramBot()
{             
  DataSet ds = DataAccess.ExecuteDataset(Setting.ConnectionString(), "GetPostForTelegramBot");
if (ds != null && ds.Tables.Count > 0)
{
   for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
   {
       var imageData = webClient.DownloadData(MediaPath + ds.Tables[0].Rows[i]["Url"].ToString());
       ms = new MemoryStream(imageData);       
       var sb = new StringBuilder();
       sb.Append(ds.Tables[0].Rows[i]["Description"].ToString());                                 

           await Bot.SendPhotoAsync("@abcgrop", new FileToSend(ds.Tables[0].Rows[i]["Url"].ToString(), ms), sb.ToString()); // here i am getting error

  }
 }
}

this is my code and i am getting error.这是我的代码,我收到错误。

Hi Set The API Timeout Propriety to Higher value like 5 mins.嗨,将 API超时属性设置为更高的值,例如 5 分钟。 you maybe having some network issues.你可能有一些网络问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM