1
votes

I'm using the getAsync(URL).Result function inside an SSIS C# task. In the debug window I can see the Result="{Not yet computed}".

The code is working very well for the last 1 year, although stops working after a new release of the API came up. It seems it's not waiting for the response. MY CODE:

public void Main()
{

    GetRequest(Dts.Variables["User::URL"].Value.ToString());
    Dts.TaskResult = (int)ScriptResults.Success;
}

private static void GetRequest(string url)
{
   try
   {
      HttpClient client = new HttpClient();
      HttpResponseMessage response = client.GetAsync(url).Result;
      response.EnsureSuccessStatusCode();
   }
   catch (Exception e)
   {
      System.Console.WriteLine("Caught Exception: " + e.Message);
   }
}

Can someone give me some insights?

Thank you

1
Sounds like a TLS authentication issue. Five years ago the industry decided to eliminate TLS 1.0/1.1 due to security issues. In June this year Microsoft pushed a security update disabling TLS 1.0/1.1 and now require clients to use TLS 1.2/1.3. So adding to your code following seems to solve issue : ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; - jdweng
Where should I add this peace of code? - Vitor Soares
Before : HttpClient client = new HttpClient(); - jdweng
Perfect. Thank you for your help. You saved my life :) Its working now :) - Vitor Soares
For the last two months I've been giving this answer a few times a day. - jdweng

1 Answers

0
votes

Thank you @jdweng

Copy of the comment that helps me to solve the issue:

Sounds like a TLS authentication issue. Five years ago the industry decided to eliminate TLS 1.0/1.1 due to security issues. In June this year Microsoft pushed a security update disabling TLS 1.0/1.1 and now require clients to use TLS 1.2/1.3. So adding to your code following seems to solve issue : ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;