One beautiful day I found the following exception from application error logs: “Authentication failed because the remote party has closed the transport stream exception” and one of our integrations was down. The problem occured only in ASP.NET MVC application. Background services using same external service were not affected. Here’s the solution.
We had to enable more security protocols in web application. Add the following line somewhere in your ASP.NET MVC application.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
My application is using .NET Framework 4.6.2. Sufficient explanations abour security protocols are available at Perficient blog post TLS 1.2 and .NET Support: How to Avoid Connection Errors.