kevbite / CompaniesHouse.NET

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

No connection could be made because the target machine actively refused it #112

Closed shauncassingham closed 4 years ago

shauncassingham commented 5 years ago

Trying to use CompanySearch, but coming up with the following error when awaiting the result;

System.AggregateException HResult=0x80131500 Message=One or more errors occurred. (No connection could be made because the target machine actively refused it) Source=System.Private.CoreLib StackTrace: at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) at CompaniesHouseRequester.Program.Main(String[] args) in

.....\Program.cs:line 102

Inner Exception 1: HttpRequestException: No connection could be made because the target machine actively refused it

Inner Exception 2: SocketException: No connection could be made because the target machine actively refused it

shauncassingham commented 5 years ago

could this be due to the correct IP not being on the white list?

wreid306 commented 5 years ago

Could maybe also be due to the tls1.2 requirement If so, to get round it in my asp.net project i had to put the following in my global.asax, application_start

protected void Application_Start(object sender, EventArgs e) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; }

kevbite commented 5 years ago

What version of .NET are you running, we've had previous people raising a similar issue which was fixed by fixing the TLS to 1.2?

If it's not whitelisted then you'll not be able to access the services too.

shauncassingham commented 5 years ago

Hi folks, thanks for the quick responses. I'm running, .NetFramework 4.5, .NETStandard 1.1 and .NetCore 2.2

Would the whitelist error be different? I'm struggling to find my outwardly facing IP through the firewalls etc.

kevbite commented 5 years ago

Does the machine that you're running it on have outbound access to the internet on port 443?

shauncassingham commented 5 years ago

i'll have to check this

shauncassingham commented 5 years ago

I can confirm that running my code on another machine outside of that network produces the expected result. I will work on this issue and report back when I find what the cause is, for future reference.

kevbite commented 5 years ago

@shauncassingham thanks for the update!