0

I'm making a simple integration with telegram-bot to send messages to a channel. The code below is working locally, but when I try it live it gives me this error.

Code

        ServicePointManager.Expect100Continue = true;
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
        string urlString = $"https://api.telegram.org/bot{apilToken}/sendMessage?chat_id={destID}&text={text}";
        WebClient webclient = new WebClient();
        webclient.DownloadString(urlString);

Error

The request was aborted: Could not create SSL/TLS secure channel.

[WebException: The request was aborted: Could not create SSL/TLS secure channel.]
   System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) +298
   System.Net.WebClient.DownloadString(Uri address) +106
   System.Net.WebClient.DownloadString(String address) +32
Axarydax
  • 16,353
  • 21
  • 92
  • 151
StarkMath
  • 121
  • 1
  • 3
  • might want to enable logging as mentioned here https://stackoverflow.com/questions/2859790/the-request-was-aborted-could-not-create-ssl-tls-secure-channel – shat90 Dec 28 '20 at 15:12
  • There are a number of problems that could cause this error. Have you attempted to make the connection manually (e.g. by opening a browser and pointing it at the same location)? The browser may give you more information about the error. – John Wu Dec 28 '20 at 17:51
  • I have tried to make the connection manually, and it works, that's the strange part. – StarkMath Dec 28 '20 at 18:50

1 Answers1

0

Are you using an SSL certificate, because you need to be using one. Have a look at this post, does this solve your problem? Telegram Bot SSL Error

Thom
  • 111
  • 1
  • 3
  • Thank you for your answer! I'm using an SSL certificate, I installed it into using the Plesk Admin of Goddady, where the app is hosted. Maybe you know if there is something I need to do to specify this in code directly while making a call to telegram? – StarkMath Dec 28 '20 at 18:49