TelegramBots / Telegram.Bot

.NET Client for Telegram Bot API
https://telegrambots.github.io/book
MIT License
3.23k stars 693 forks source link

Exception on GetMe or GetUpdates #70

Closed 2steuer closed 8 years ago

2steuer commented 8 years ago

Hi,

Since yesterday everythin worked fine, but now i always get the following exception von GetMe or GetUpdates. Using Telegram.bot under mono 4.

[07.01.2016 - 13:15:23.780/Error] (Telegram) Exception: System.AggregateException / One or more errors occurred.
   at System.Threading.Tasks.Task.ThrowIfExceptional (Boolean includeTaskCanceledExceptions) <0xb5490670 + 0x00049> in <filename unknown>:0
  at System.Threading.Tasks.Task`1[TResult].GetResultCore (Boolean waitCompletionNotification) <0xb547df90 + 0x00077> in <filename unknown>:0
  at System.Threading.Tasks.Task`1[TResult].get_Result () <0xb547df10 + 0x00035> in <filename unknown>:0
  at AlarmSystem.Plugin.Telegram.TelegramHandler._rcvTimer_Elapsed (System.Object sender, System.Timers.ElapsedEventArgs e) <0xb409dfd0 + 0x000ef> in <filename unknown>:0

Can someone help? :-(

MrRoundRobin commented 8 years ago

Can you send the InnerException?

2steuer commented 8 years ago

This is the information mono reveals:

Inner: Telegram.Bot.Types.ApiRequestException: Exception of type 'Telegram.Bot.Types.ApiRequestException' was thrown. at Telegram.Bot.Api+d__45`1[T].MoveNext () <0xb3aed000 + 0x012cf> in :0

2steuer commented 8 years ago

Or even a little more... Talking about exceptions, Mono is not that helpful...

[07.01.2016 - 13:47:45.167/Error] (SYSTEM/CRITICAL) Exception: System.AggregateException / One or more errors occurred.
   at System.Threading.Tasks.Task.ThrowIfExceptional (Boolean includeTaskCanceledExceptions) <0xb5490670 + 0x00049> in <filename unknown>:0
  at System.Threading.Tasks.Task`1[TResult].GetResultCore (Boolean waitCompletionNotification) <0xb547df90 + 0x00077> in <filename unknown>:0
  at System.Threading.Tasks.Task`1[TResult].get_Result () <0xb547df10 + 0x00035> in <filename unknown>:0
  at AlarmSystem.Plugin.Telegram.TelegramHandler.GetMe () <0xb410ac10 + 0x00023> in <filename unknown>:0
  at AlarmSystem.Plugin.Telegram.TelegramHandler.Start () <0xb410aae0 + 0x00013> in <filename unknown>:0
  at AlarmSystem.AlarmSystemService.OnStart (System.String[] args) <0xb7175728 + 0x017ea> in <filename unknown>:0 . Inner: Telegram.Bot.Types.ApiRequestException: Exception of type 'Telegram.Bot.Types.ApiRequestException' was thrown.
  at Telegram.Bot.Api+<SendWebRequest>d__45`1[T].MoveNext () <0xb410b088 + 0x012cf> in <filename unknown>:0

Unhandled Exception:
System.AggregateException: One or more errors occurred. ---> Telegram.Bot.Types.ApiRequestException: Exception of type 'Telegram.Bot.Types.ApiRequestException' was thrown.
  at Telegram.Bot.Api+<SendWebRequest>d__45`1[T].MoveNext () <0xb410b088 + 0x012cf> in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.ThrowIfExceptional (Boolean includeTaskCanceledExceptions) <0xb5490670 + 0x00049> in <filename unknown>:0
  at System.Threading.Tasks.Task`1[TResult].GetResultCore (Boolean waitCompletionNotification) <0xb547df90 + 0x00077> in <filename unknown>:0
  at System.Threading.Tasks.Task`1[TResult].get_Result () <0xb547df10 + 0x00035> in <filename unknown>:0
  at AlarmSystem.Plugin.Telegram.TelegramHandler.GetMe () <0xb410ac10 + 0x00023> in <filename unknown>:0
  at AlarmSystem.Plugin.Telegram.TelegramHandler.Start () <0xb410aae0 + 0x00013> in <filename unknown>:0
  at AlarmSystem.AlarmSystemService.OnStart (System.String[] args) <0xb7175728 + 0x017ea> in <filename unknown>:0
---> (Inner Exception #0) Telegram.Bot.Types.ApiRequestException: Exception of type 'Telegram.Bot.Types.ApiRequestException' was thrown.
  at Telegram.Bot.Api+<SendWebRequest>d__45`1[T].MoveNext () <0xb410b088 + 0x012cf> in <filename unknown>:0 <---

[ERROR] FATAL UNHANDLED EXCEPTION: System.AggregateException: One or more errors occurred. ---> Telegram.Bot.Types.ApiRequestException: Exception of type 'Telegram.Bot.Types.ApiRequestException' was thrown.
  at Telegram.Bot.Api+<SendWebRequest>d__45`1[T].MoveNext () <0xb410b088 + 0x012cf> in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.ThrowIfExceptional (Boolean includeTaskCanceledExceptions) <0xb5490670 + 0x00049> in <filename unknown>:0
  at System.Threading.Tasks.Task`1[TResult].GetResultCore (Boolean waitCompletionNotification) <0xb547df90 + 0x00077> in <filename unknown>:0
  at System.Threading.Tasks.Task`1[TResult].get_Result () <0xb547df10 + 0x00035> in <filename unknown>:0
  at AlarmSystem.Plugin.Telegram.TelegramHandler.GetMe () <0xb410ac10 + 0x00023> in <filename unknown>:0
  at AlarmSystem.Plugin.Telegram.TelegramHandler.Start () <0xb410aae0 + 0x00013> in <filename unknown>:0
  at AlarmSystem.AlarmSystemService.OnStart (System.String[] args) <0xb7175728 + 0x017ea> in <filename unknown>:0
---> (Inner Exception #0) Telegram.Bot.Types.ApiRequestException: Exception of type 'Telegram.Bot.Types.ApiRequestException' was thrown.
  at Telegram.Bot.Api+<SendWebRequest>d__45`1[T].MoveNext () <0xb410b088 + 0x012cf> in <filename unknown>:0 <---
2steuer commented 8 years ago

Additionally, after updating to the new version yesterday, i got System.IO.FileNotFoundExceptions for System.Net.Http and System.Net.Http.Formatting. I fixed these by ticking "Local copy" to True in the properties dialog of the referecnes.

Maybe this helps?

MrRoundRobin commented 8 years ago

can you put something like the following around the problematic code:

try {
  //your code
} catch (AggregateException e) {
  throw e.InnerException;
}
2steuer commented 8 years ago

This is whats being thrown:

Unhandled Exception: Telegram.Bot.Types.ApiRequestException: Exception of type 'Telegram.Bot.Types.ApiRequestException' was thrown. at AlarmSystem.Plugin.Telegram.TelegramHandler.Start () <0xb407f998 + 0x0007f> in :0 at AlarmSystem.AlarmSystemService.OnStart (System.String[] args) <0xb70ed728 + 0x017ea> in :0 [ERROR] FATAL UNHANDLED EXCEPTION: Telegram.Bot.Types.ApiRequestException: Exception of type 'Telegram.Bot.Types.ApiRequestException' was thrown. at AlarmSystem.Plugin.Telegram.TelegramHandler.Start () <0xb407f998 + 0x0007f> in :0 at AlarmSystem.AlarmSystemService.OnStart (System.String[] args) <0xb70ed728 + 0x017ea> in :0

2steuer commented 8 years ago

Fixed by building from source. No idea what the problem was, but you could please check you NuGET Package :-) Also, I noticed quite a lot of dependencies in NuGET, while only WebApi and JSON Serializer are needed. When building from source one can safely delete those dependencies.

MrRoundRobin commented 8 years ago

i changed to the new project type, so now there should be dependencies per platform...

amosadegh commented 7 years ago

hi i am using this telegram bot , when more then 1 user using my bot synchronous, the message send to another user , how can i use this telegram bot in threading mode thanks