Secure connection error when sending emails/telegrams

Created at 16 Mar 2020, 11:11
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
GU

guillermo

Joined 07.06.2019

Secure connection error when sending emails/telegrams
16 Mar 2020, 11:11


Hello,
with the recent update to version 3.7 I am getting errors when sending emaila and telegram messages.
This error did not happen until recently, that's why I relate it to the version update, although I don't know for sure if that is the cause.

I attach below a sample code. Please set the email addresses, chat id and bot token with your own values.

The error when sending emails is that the SMTP server requires a secure connection.
The error when sending a Telegram message is that it cannot create a secure channel SSL/TLS.

Any help is appreciated.
Thanks!!
 

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
using System.Net;
using System.Web;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.WEuropeStandardTime, AccessRights = AccessRights.FullAccess)]
    public class TelegramTest : Robot
    {


        [Parameter("To email address", Group = "Communication", DefaultValue = "xxxx@gmail.com")]
        public string ParamToEmailAddress { get; set; }

        [Parameter("From email address", Group = "Communication", DefaultValue = "yyyy@gmail.com")]
        public string ParamFromEmailAddress { get; set; }

        [Parameter("Telegram chat id", Group = "Communication", DefaultValue = "123456789")]
        public string ParamTelegramChatId { get; set; }

        [Parameter("Telegram bot token", Group = "Communication", DefaultValue = "123456789:AAEaWiH4QdHJ3HYNa6AS0L_XXXXXXXXXXXX")]
        public string ParamTelegramBotToken { get; set; }


        private string telegramURL;

        protected override void OnStart()
        {
            this.telegramURL = "https://api.telegram.org/bot" + this.ParamTelegramBotToken + "/sendMessage?chat_id=" + this.ParamTelegramChatId + "&text=";

            try
            {
                this.sendEmailMessage("Test", "Test");
            } catch (Exception exc)
            {
                Print(exc.ToString());
            }

            try
            {
                this.sendTelegram("Test");
            } catch (Exception exc)
            {
                Print(exc.ToString());
            }
        }


        private void sendTelegram(string message)
        {
            WebRequest request = WebRequest.Create(this.telegramURL + HttpUtility.UrlEncode(message));
            request.Method = "GET";
            WebResponse response = request.GetResponse();
            response.Close();
        }

        private void sendEmailMessage(string subject, string message)
        {
            Notifications.SendEmail(this.ParamFromEmailAddress, this.ParamToEmailAddress, subject, message);
        }
    }
}

 


@guillermo
Replies

ClickAlgo
16 Mar 2020, 11:30

you can find the fix here.

.

Paul Hayes
Sales & Marketing
Emailcontact@clickalgo.com
Phone: (44) 203 289 6573
Websitehttps://clickalgo.com

Twitter | Facebook | YouTube | Pinterest | LinkedIn

PS: Why not join our instant chat group on Telegram.


@ClickAlgo