简体   繁体   中英

.Net Core Telegram.Bot failed with error "SSL Connection could not be established"

I try to use this telegram bot library. My code is simple:

using System;
using System.Threading.Tasks; 
using Telegram.Bot;
namespace telegram
{
    class Program
    {
        private static string token = "mytoken";
        private static string msg = "Test";
        private static int chatId = 11111111;    
        static async Task Main(string[] args)
        {
            var bot = new TelegramBotClient(token);
            await bot.SendTextMessageAsync(chatId, msg); 
        }
    }
}

But after compilation, I get this error message:

#

Inner exception 1:

在此处输入图片说明

Inner exception 2: Win32Exception: An unexpected message was received or it is in the wrong format.

I believe there is an elementary error and its solution, but, unfortunately, I do not know what the problem is.

From the docs "Bots can't initiate conversations with users."

You need to wait for a user to call your bot bot.OnMessage += BotOnMessageReceived and then you can respond. You can't create ChatIDs, the system does that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM