[英]Telegram Bot: Wrong response from the webhook: 404 Bad Request
I have my telegram bot deployed on Heroku.我的电报机器人部署在 Heroku 上。 Bot used to work fine, but at some point it just stopped sending messages when receiving commands.
Bot 过去可以正常工作,但在某些时候它只是在接收命令时停止发送消息。 here is the answer of getWebHookInfo:
这是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":"Wrong response from the webhook: 404 Not Found","max_connections":40,"ip_address":"54.171.62.111"}}
{"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"}}
I have no idea what happened.我不知道发生了什么。 Bot worked as usual, and suddenly that happens.
Bot 像往常一样工作,突然间发生了这种情况。 Bot is using port 443 for https requests.
Bot 正在为 https 请求使用端口 443。 Also sometimes logs say "Failed to determine the https port for redirect".
有时日志也会显示“无法确定 https 端口进行重定向”。
Its probably because your page is not found.可能是因为找不到您的页面。 https://telegram-rainbow-bot.herokuapp.com/api/message/update not found !
https://telegram-rainbow-bot.herokuapp.com/api/message/update未找到! so fix this and try to set your webbook again
所以解决这个问题并尝试再次设置您的网络书
I managed to fix this issue (although I'm not sure if this is correct way).我设法解决了这个问题(尽管我不确定这是否正确)。 At first, I had problem with error code 404. This one fixes by adding UseRouting() in Configure method at Startup.cs.
起初,我遇到了错误代码 404 的问题。这是通过在 Startup.cs 的 Configure 方法中添加 UseRouting() 来解决的。 Then I had problem with error code 400. This one I fixed by installing Microsoft.AspNetCore.Mvc.NewtonsoftJson nuget package and then I added AddControllers().AddNewtonsoftJson() in ConfigureServices method at Startup.cs.
然后我遇到了错误代码 400 的问题。我通过安装 Microsoft.AspNetCore.Mvc.NewtonsoftJson nuget package 修复了这个问题,然后我在 Startup.cs 的 ConfigureServices 方法中添加了 AddControllers().AddNewtonsoftJson()。 Probably my code wasn't processing JSON from Telegram correctly.
可能我的代码没有正确处理来自 Telegram 的 JSON。 Hope it helps to anyone.
希望它对任何人都有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.