簡體   English   中英

SSIS C# HTTP GetAsync 不等待響應

[英]SSIS C# HTTP GetAsync not waiting for the response

我在 SSIS C# 任務中使用 getAsync(URL).Result 函數。 在調試窗口中,我可以看到 Result="{尚未計算}"。

該代碼在過去 1 年中運行良好,但在 API 的新版本發布后停止工作。 似乎不是在等待回應。 我的代碼:

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);
   }
}

有人可以給我一些見解嗎?

謝謝

謝謝@jdweng

幫助我解決問題的評論副本:

聽起來像是 TLS 身份驗證問題。 五年前,由於安全問題,業界決定取消 TLS 1.0/1.1。 今年 6 月,微軟推出了禁用 TLS 1.0/1.1 的安全更新,現在要求客戶端使用 TLS 1.2/1.3。 因此,添加到您的代碼中似乎可以解決問題: ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM