Host Problem, Help Please.
emreordukaya opened this issue · 8 comments
Hi I want to host this ASP .Net Core 3.1 Web Hook application or Classic ASP .Net application on Server only. no azure. only server host.
So for ASP .Net Core 3.1 Web Hook application how can adjust settings on Main method?
public static void Main()
{
// Endpoint must be configured with netsh:
// netsh http add urlacl url=https://+:8443/ user=
// netsh http add sslcert ipport=0.0.0.0:8443 certhash= appid=
using (WebApp.Start<Startup>("https://+:8443"))
{
// Register WebHook
// You should replace {YourHostname} with your Internet accessible hosname
Bot.Api.SetWebhookAsync("https://{YourHostname}:8443/WebHook").Wait();
Console.WriteLine("Server Started");
// Stop Server after <Enter>
Console.ReadLine();
// Unregister WebHook
Bot.Api.DeleteWebhookAsync().Wait();
}
}
in this code block;
// Endpoint must be configured with netsh:
// netsh http add urlacl url=https://+:8443/ user=
// netsh http add sslcert ipport=0.0.0.0:8443 certhash= appid=
how can I set on Server? should I have admin rights on Server?
=====================
Other side; Classic ASP .Net application how can adjust settings on appsettings.json
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
},
"BotConfiguration": {
"BotToken": "",
"Socks5Host": "",
"Socks5Port": ""
}
}
plus is it need to appsettings.Development.json file?
plus should I do any more adjust to host Server?
===============
I can use one of them. Thank you for your replys.
First of all, you need to have a valid SSL certificate issued by a real certification authority (for example, Let's Encrypt). If you want to use the self-signed certificate, you need to share it with Telegram Servers by passing the public key file as second parameter of SetWebhookAsync method.
Also port 8443 must be allowed by your firewall.
Also after setting the webhook, you need to receive the requests on /Webhook route and process them manually. Events don't work while receiving the webhook.
appsettings.Development.json
is usually used for overwriting the default configuration while running the application in Development environment. This file is optional.
thanks.
First of all, you need to have a valid SSL certificate issued by a real certification authority (for example, Let's Encrypt). If you want to use the self-signed certificate, you need to share it with Telegram Servers by passing the public key file as second parameter of SetWebhookAsync method.
Also port 8443 must be allowed by your firewall.
thanks. How to use this certificate as a second parameter. can u share code.
And should I have to get physical certifiate file, right?
appsettings.Development.json
is usually used for overwriting the default configuration while running the application in Development environment. This file is optional.
Can I delete this file, if I wont use for development ?
@eordukaya yes, that's right, you should have a .pfx
file locally as far as I remember.
You need to open the file for read:
using (var cert = File.OpenRead("cert.pfx"))
{
await botClient.SetWebhookAsync("url", new InputOnlineFile(cert, "cert.pfx"));
}
Something like that. But note that you have to await the SetWebhookAsync
method, otherwise the file will be disposed before sending.
And yes, you can delete development file.
I’m closing this issue because it has been inactive for a few months. This probably means that it is not reproducible or it has been fixed in a newer version.
Please reopen if you still encounter this issue with the latest stable version and then please use the issue template.