kevbite / CompaniesHouse.NET

A simple .NET client wrapper for CompaniesHouse API
MIT License
37 stars 44 forks source link

The underlying connection was closed: An unexpected error occurred on a send. #111

Closed AlwaysVbNet closed 5 years ago

AlwaysVbNet commented 5 years ago

Hi @kevbite ,

I am getting an error InnerException = {"The underlying connection was closed: An unexpected error occurred on a send."}

when calling this function:

  public Task<CompaniesHouseClientResponse<CompanyProfile>> GetCompanyProfileAsync(string companyNumber, CancellationToken cancellationToken = default(CancellationToken))
        {
            return _companiesHouseCompanyProfileClient.GetCompanyProfileAsync(companyNumber, cancellationToken);
        }

The service was working fine until a few days ago.

Any ideas?

ermserg commented 5 years ago

I'm getting the same exception since about 2 months ago. Any solutions?

kevbite commented 5 years ago

Is this related to #112? I've just run all the tests locally and everything is passing so I'm guessing it's your environment that you're running in.

ermserg commented 5 years ago

The code below has resolved the issue, thank you!

void Application_Start(object sender, EventArgs e)
{
    System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
}
kevbite commented 5 years ago

@ermserg glad that sorted your issue. I'm going to close this issue but feel free to open another if you have any other problems. Thanks