C# 如何解决电报中webhook设置错误
我在电报中有一个机器人,并试图在Plesk主机中运行它(在端口443有SSL) 当我在VisualStudio中运行robot页面时,bot运行得很好。 在我将项目发布/上传到我的plesk主机并打开robot页面后,bot也运行良好 但是设置webhook后,bot不会运行。 在webhookInfo中1.6分钟后,我得到以下信息:C# 如何解决电报中webhook设置错误,c#,bots,telegram,C#,Bots,Telegram,我在电报中有一个机器人,并试图在Plesk主机中运行它(在端口443有SSL) 当我在VisualStudio中运行robot页面时,bot运行得很好。 在我将项目发布/上传到我的plesk主机并打开robot页面后,bot也运行良好 但是设置webhook后,bot不会运行。 在webhookInfo中1.6分钟后,我得到以下信息: { "ok":true, "result":{ "url":"htt
{
"ok":true,
"result":{
"url":"https://MYDOMAIN:443/Robot.aspx",
"has_custom_certificate":false,
"pending_update_count":1,
"last_error_date":1598521211,
"last_error_message":"Read timeout expired",
"max_connections":40
}
}
Conflict: can't use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first
我的源代码:
public class Robot : Page
{
private const string Token = "1257942485:AAFMeYMX187lEeN8XHCEtSyCVoXXXX";
private HttpToSocks5Proxy proxy = new HttpToSocks5Proxy(
socks5Hostname: "so5tel.XXXX.org",
socks5Port: 6500,
username: "XXXX",
password: "XXXX"
);
private static ITelegramBotClient _botClient;
protected void Page_Load(object sender, EventArgs e)
{
proxy.ResolveHostnamesLocally = true;
RegisterAsyncTask(new PageAsyncTask(RunBot));
ExecuteRegisteredAsyncTasks();
}
private async Task RunBot()
{
_botClient = new TelegramBotClient(Token, proxy);
_botClient.OnMessage += Bot_OnMsgAsync;
_botClient.OnReceiveError += _botClient_OnReceiveError;
_botClient.StartReceiving();
}
async void Bot_OnMsgAsync(object sender, MessageEventArgs e)
{
await _botClient.SendTextMessageAsync(e.Message.Chat.Id, e.Message.Text).ConfigureAwait(false);
}
private void _botClient_OnReceiveError(object sender, ReceiveErrorEventArgs e)
{
using (StreamWriter we = new StreamWriter(Server.MapPath("file.txt"), true))
{
we.WriteLine(e.ApiRequestException.Message + DateTime.Now);
}
}
}
在file.txt中,我得到以下信息:
{
"ok":true,
"result":{
"url":"https://MYDOMAIN:443/Robot.aspx",
"has_custom_certificate":false,
"pending_update_count":1,
"last_error_date":1598521211,
"last_error_message":"Read timeout expired",
"max_connections":40
}
}
Conflict: can't use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first
我怎样才能解决它