question

KathiresanSubramaniam-1168 avatar image
0 Votes"
KathiresanSubramaniam-1168 asked 17NBhoodoo-8451 answered

Custom .NET Activity: The request was aborted: Could not create SSL/TLS secure channel. Unable to download API data.

Under the Batch Service option, we are running a custom dot net activity, and that .NET tool downloads data from some APIs. It was working fine without any issues until Yesterday(for more than 2/3 years). Now we are facing the below error while downloading data from the APIs. I don't know why we are facing such issue suddenly.

Error: The request was aborted: Could not create SSL/TLS secure channel.
StackTrace: at System.Net.WebClient.OpenRead(Uri address)
at Import.DownloadSite(String url, String type)

The same .NET tool works fine in our local desktop machines(Windows 10 OS). Getting the error only in the batch account machine. So I think the problem is in the batch account machine.

Using the below C# code for downloading data from the APIs:

 WebClient wc = new WebClient();
 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
 return wc.DownloadString(string.Format(ApiUrl, type));

I tried most of the solutions suggested in the below link, and nothting works for me.
https://stackoverflow.com/questions/2859790/the-request-was-aborted-could-not-create-ssl-tls-secure-channel

More information:
.NET Framework: v4.5
Batch machine: Windows Server 2012 R2 (x64)


azure-data-factoryazure-batch
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ChiragMishra-MSFT avatar image
1 Vote"
ChiragMishra-MSFT answered LawrencePatrick-4025 published

Hi @KathiresanSubramaniam-1168,


You need to Add HTTP Header "Expect" with value "100-continue". In your case, please add these lines of code before creating the request :


 ServicePointManager.Expect100Continue = true;
 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
        | SecurityProtocolType.Tls11
        | SecurityProtocolType.Tls12
        | SecurityProtocolType.Ssl3;



Hope this helps.


· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @KathiresanSubramaniam-1168,

Just wanted to check - was the above suggestion helpful to you? If yes, please consider upvoting and/or accepting it as answer. This would help other community members reading this thread.

0 Votes 0 ·

Hi @KathiresanSubramaniam-1168,

We have not received a response from you. Are you still facing the issue? If above solution from Chirag helped, would you please share it here with the community? Otherwise, let us know and we will continue to engage with you on the issue.

Do click on "Accept Answer" and Upvote on the post that helps you, this can be beneficial to other community members.

0 Votes 0 ·

This fixed my issue. Thank you!!!

changed:
var client = new WebClient();
AddHeader(H, client);
To:
var client = new WebClient();
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
| SecurityProtocolType.Tls11
| SecurityProtocolType.Tls12
| SecurityProtocolType.Ssl3;
AddHeader(H, client);

0 Votes 0 ·
BimanMondal-1994 avatar image
0 Votes"
BimanMondal-1994 answered BimanMondal-1994 published

I am facing the same issue as mentioned in the original thread.

log :
[08/04/2020 17:39:27,846] VSTA_Main: URI: https://xxxx-d.openstack.sas.com/locales
[08/04/2020 17:39:27,864] VSTA_Main: Method: GET
[08/04/2020 17:39:27,884] VSTA_Main: ContentType:
[08/04/2020 17:39:27,892] VSTA_Main: Accept:
[08/04/2020 17:39:27,905] VSTA_Main: AcceptLanguage: en-US
[08/04/2020 17:39:27,983] VSTA_Main: ReqBody: "en"
[08/04/2020 17:39:28,011] --------------- EXCEPTION REPORT ---------------
[08/04/2020 17:39:28,058] CreateNInitiateREST:
[08/04/2020 17:39:28,070] System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
at System.Net.HttpWebRequest.GetResponse()
at SAS.FM.Common.RESTHelper.CreateNInitiateREST[RESPONSE](String URI, String Token, String Method, String ContentType, WebHeaderCollection Headers, Object ReqBody, Int32& ResponseCode, String Accept, String AcceptLanguage, Boolean hide4XX, Boolean returnEtag)
[08/04/2020 17:39:28,096] ----------- END OF EXCEPTION REPORT ------------
[08/04/2020 17:39:28,124] --------------- EXCEPTION REPORT ---------------
[08/04/2020 17:39:28,153] Failed to reconnect with server.
[08/04/2020 17:39:28,182] System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
at System.Net.HttpWebRequest.GetResponse()

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

17NBhoodoo-8451 avatar image
0 Votes"
17NBhoodoo-8451 answered

by sam



Error>
<Code>ResourceNotFound</Code>
<Message>The specified resource does not exist. RequestId:97a49709-101e-005a-5801-0a46fa000000 Time:2021-02-23T16:33:15.5463336Z</Message>
</Error>


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.