SSIS C#HTTP GetAsync不等待响应 [英] SSIS C# HTTP GetAsync not waiting for the response

查看:87
本文介绍了SSIS C#HTTP GetAsync不等待响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在SSIS C#任务中使用了getAsync(URL).Result函数.在调试窗口中,我可以看到Result ="{尚未计算}".

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}".

在过去的1年中,该代码运行良好,不过在新版API发布后就停止了工作.似乎不是在等待响应.我的密码:

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?

谢谢

推荐答案

谢谢@jdweng

可以帮助我解决问题的评论副本:

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

听起来像TLS身份验证问题.五年前,由于安全问题,业界决定取消TLS 1.0/1.1.微软在今年6月推出了一项安全更新,以禁用TLS 1.0/1.1,现在要求客户端使用TLS 1.2/1.3.因此,在代码中添加以下内容似乎可以解决问题:ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

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;

这篇关于SSIS C#HTTP GetAsync不等待响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆