简体   繁体   English

Telegram Bot:来自 webhook 的错误响应:404 Bad Request

[英]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.

相关问题 使用ngrok 502 Bad Getaway设置电报Bot Webhook - setting up telegram bot webhook with ngrok 502 Bad Getaway 使用Telegram Bot发送消息时出现错误400错误的请求 - Error 400 bad request while sending message with Telegram Bot 电报bot c#webhook和winform中的getupdates - telegram bot c# webhook and getupdates in winform Telegram bot api 从键盘按钮接收响应 - Telegram bot api receive response from keboard buttons 我应该在哪里配置 webhook url 从 bot 添加电报组获取最新的用户发送消息 - Where should I configure webhook url to get the latest user send message from bot added telegram group 响应并非来自单击Microsoft Bot Framework机器人电报中的按钮 - The response does not come from clicking a button in the bot Telegram by the Microsoft Bot Framework 电报机器人如何通过Webhook C#回答问题 - Telegram bot how to make answering to the questions via webhook c# 如何通过 webhook 获取 Telegram.Bot.Types.Update? - How get Telegram.Bot.Types.Update through webhook? Telegram Bot无法通过放入服务器和使用Webhook来工作 - Telegram Bot don't work by putting into server and use of webhook Bot Framework C#Luis Getting>异常:响应状态代码未指示成功:400(错误请求) - Bot Framework C# Luis Getting > Exception: Response status code does not indicate success: 400 (Bad Request)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM