Tuesday 16 April 2019

The underlying connection was closed an unexpected error occurred on a send

Hi,

Today I was working on calling some external url via C# code using HttpRequest and I was continuously getting the below error.

The underlying connection was closed an unexpected error occurred on a send.

There could be multiple reasons for this but adding the below line before sending the request helped to fix the issue.


ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12

Hope this helps.

--
Happy Coding
Gopinath

No comments:

Post a Comment