TelegramBot application stop working with this errors (SocketException,IOException,WebException,HttpRequestException)

时间:2017-12-18 05:36:08

标签: c# asp.net telegram-bot

I don't know what can i do.My telegrambot project suddenly stop working after about 1 day.with this errors. please help me,if possible.

Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Net.Sockets.SocketException
at System.Net.Sockets.Socket.EndReceive(System.IAsyncResult)
at System.Net.Sockets.NetworkStream.EndRead(System.IAsyncResult)

Exception Info: System.IO.IOException
at System.Net.Security._SslStream.EndRead(System.IAsyncResult)
at System.Net.TlsStream.EndRead(System.IAsyncResult)
at System.Net.PooledStream.EndRead(System.IAsyncResult)
at System.Net.Connection.ReadCallback(System.IAsyncResult)

Exception Info: System.Net.WebException
at System.Net.HttpWebRequest.EndGetResponse(System.IAsyncResult)
at System.Net.Http.HttpClientHandler.GetResponseCallback(System.IAsyncResult)

Exception Info: System.Net.Http.HttpRequestException
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].GetResult() at Telegram.Bot.TelegramBotClient+<SendWebRequestAsync>d__1091[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext()

Exception Info: System.AggregateException
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean)
at System.Threading.Tasks.Task1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].GetResultCore(Boolean) at System.Threading.Tasks.Task1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].get_Result()
at Mybot.BotForm.RunBot()
at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()

1 个答案:

答案 0 :(得分:1)

因为你的汇集方式。可能您的应用程序内存不足或网络连接。您可以简单地忽略此异常,操作系统将处理它,但如果您打算将其用作长轮询方法,则应在每次请求后仔细处理对象。 我强烈建议使用webhook而不是获取更新方法。它的速度和效率都快得多。