【问题标题】:Telegram Bot: Wrong response from the webhook: 404 Bad RequestTelegram Bot:来自 webhook 的错误响应:404 Bad Request
【发布时间】:2021-02-18 16:51:55
【问题描述】:

我在 Heroku 上部署了我的电报机器人。 Bot 过去可以正常工作,但在某些时候它只是在接收命令时停止发送消息。这是getWebHookInfo的答案:

{"ok":true,"result":{"url":"https://telegram-rainbow-bot.herokuapp.com:443/api/message/update","has_custom_certificate":false," pending_update_count":1,"last_error_date":1613676609,"last_error_message":"来自 webhook 的错误响应:404 Not Found","max_connections":40,"ip_address":"54.171.62.111"}}

我不知道发生了什么。 Bot 像往常一样工作,突然间发生了这种情况。 Bot 使用端口 443 进行 https 请求。有时日志也会显示“无法确定重定向的 https 端口”。

【问题讨论】:

    标签: c# heroku telegram-bot


    【解决方案1】:

    我设法解决了这个问题(尽管我不确定这是否正确)。起初,我遇到了错误代码 404 的问题。这是通过在 Startup.cs 的 Configure 方法中添加 UseRouting() 来解决的。然后我遇到了错误代码 400 的问题。我通过安装 Microsoft.AspNetCore.Mvc.NewtonsoftJson nuget 包修复了这个问题,然后我在 Startup.cs 的 ConfigureServices 方法中添加了 AddControllers().AddNewtonsoftJson()。可能我的代码没有正确处理来自 Telegram 的 JSON。希望它对任何人都有帮助。

    【讨论】:

      【解决方案2】:

      可能是因为找不到您的页面。 https://telegram-rainbow-bot.herokuapp.com/api/message/update 未找到! 所以解决这个问题并尝试重新设置你的网络书

      【讨论】:

      • 好的,所以我设法使这个页面可用。 GET 方法有效,但 POST 方法失败,错误代码为 400。Telegram 是否发送了错误的 JSON 或其他内容?
      • 我不熟悉 ASP,但我认为电报端没有问题,您必须修复代码才能使其正常工作..
      猜你喜欢
      • 1970-01-01
      • 2021-04-21
      • 1970-01-01
      • 2016-07-15
      • 2019-06-26
      • 1970-01-01
      • 2020-08-14
      • 1970-01-01
      • 2021-12-29
      相关资源
      最近更新 更多