O
O
oleg_ka2016-10-23 14:37:20
ASP.NET
oleg_ka, 2016-10-23 14:37:20

Why does Telegram bot give 502 Bad Gateway on Http request?

There is a telegram bot on ASP.NET with the following code:

private void Start()
        {
            using (WebApp.Start<Startup>("http://*:8080/"))
            {
                Bot.token.SetWebhookAsync("https://адрес/WebHook").Wait();
            }
        }

 public class Startup
    {
        public static void Configuration(IAppBuilder app)
        {
            var config = new HttpConfiguration();
            config.Routes.MapHttpRoute("WebHook","{controller}");
            app.UseWebApi(config);
        }
    }

 public async Task<IHttpActionResult> Post(Update update)
        {
            var message = update.Message;

            if (message.Type == MessageType.TextMessage)
            {
                if (message.Text=="/game")
                {
                    await Bot.token.SendTextMessageAsync(message.Chat.Id,"Молоток");
                }
                else
                {
                    await Bot.token.SendTextMessageAsync(message.Chat.Id, "Не молоток");
                }
            }
            return Ok();
        }

The request is sent to the server, but the bot does not respond, instead of a response, a 502 Bad Gateway error is fixed.
At the same time, exactly the same code works without errors on the console.
How to fix this problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Arthur Gauser, 2016-12-11
@antimech

How to fix this problem?

Attach a log.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question