TelegramBots / Telegram.Bot

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

Error using (WebApp.Start<Startup>(“https://+:8443”)) #457

Closed imanf94 closed 7 years ago

imanf94 commented 7 years ago

I'm trying to make a telegram bot using telegram.bot nuget package and webhook method. So i'm testing this example but i face this error at first line:

An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll

Additional information: Exception has been thrown by the target of an invocation.

Here is my code:

`static void Main(string[] args) {

    using (WebApp.Start<Startup>("https://+:8443"))
    {
        // Register WebHook
        Bot.Api.SetWebhook("https://promoton.ir:8443/WebHook").Wait();

        Console.WriteLine("Server Started");

        // Stop Server after <Enter>
        Console.ReadLine();

        // Unregister WebHook
        Bot.Api.SetWebhook().Wait();
    }
}`
Olfi01 commented 7 years ago

in the exception you're getting, is there an inner exception? the error message seems to suggest that

imanf94 commented 7 years ago

@Olfi01

inner exception: {"Access is denied"}
 Data: {System.Collections.ListDictionaryInternal}
 Source: System
 StackTrace:    at System.Net.HttpListener.AddAllPrefixes()
   at System.Net.HttpListener.Start()
   at Microsoft.Owin.Host.HttpListener.OwinHttpListener.Start(HttpListener listener, Func`2 appFunc, IList`1 addresses, IDictionary`2 capabilities, Func`2 loggerFactory)
   at Microsoft.Owin.Host.HttpListener.OwinServerFactory.Create(Func`2 app, IDictionary`2 properties)
 TargetSite: {Void AddAllPrefixes()}
Olfi01 commented 7 years ago

Seems something is denying the access for the HTTP client, have you checked your firewall's settings?

imanf94 commented 7 years ago

@Olfi01 yes it'not the problem. i think, i'm missing something i used this line exactly: using (WebApp.Start("https://+:8443")) but i think i may change + to something or may add username to somewhere (the comments code say) but i don't know how?

Olfi01 commented 7 years ago

I'm sorry, but I don't know much about that ASP.NET stuff, try asking @pouladpld or @MrRoundRobin for help :/

imanf94 commented 7 years ago

@Olfi01 thank you @MrRoundRobin @pouladpld i will appreciate if you could help me.

mutluozkurt commented 4 years ago

Hi @imanf94, how did you solve this problem?

imanf94 commented 4 years ago

I don't remember exactly. But i think the problem was about the required security items such as https certificate or something. Check out the telegram required server items in order to use webhook

Get Outlook for Androidhttps://aka.ms/ghei36


From: mutluozkurt notifications@github.com Sent: Saturday, May 2, 2020 3:37:39 AM To: TelegramBots/Telegram.Bot Telegram.Bot@noreply.github.com Cc: imanf94 iman_f94@hotmail.com; Author author@noreply.github.com Subject: Re: [TelegramBots/Telegram.Bot] Error using (WebApp.Start(“https://+:8443”)) (#457)

Hi, how did you solve this problem?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/TelegramBots/Telegram.Bot/issues/457#issuecomment-622604685, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHRQLLPBI3UKOLWE474OHNLRPNI3XANCNFSM4DZZBSDA.