使用 ngrok 502 Bad Gateway 设置电报机器人 webhook

setting up telegram bot webhook with ngrok 502 Bad Getaway

我尝试像 webhook 示例一样使用 ngrok 设置机器人,这就是方法:

       using (WebApp.Start<Startup>("localhost:5229"))
        {
       
            Bot.Api.SetWebhook("https://sd52w84s.ngrok.io").Wait();

            Console.WriteLine("Server Started");

       
            Console.ReadLine();

      
            Bot.Api.SetWebhook().Wait();
        }

但是 ngrok 控制台记录 502 Bad Getaway 错误,服务器似乎不在 运行 localhost:5229

这也是邮递员的错误:

Failed to complete tunnel connection

The connection to https://sd52w84s.ngrok.io was successfully tunneled to your ngrok client, but the >client failed to establish a connection to the local address localhost:20.

Make sure that a web service is running on localhost:5229 and that it is a valid address.

The error encountered was: dial tcp [::1]:5229: connectex: No connection could be made because the >target machine actively refused it.

如何确定服务器是 运行? 任何帮助将不胜感激!

发现问题:|

using (WebApp.Start<Startup>("localhost:5229"))

必须改为

using (WebApp.Start<Startup>("http://localhost:5229/"))