DLL creating a connection fails with "An existing connection was forcibly closed by the remote host" - sockets

I have created a DLL [made available as a NuGet package (.NetStandard 2.0/2.1)].
When a particular class in this DLL is instantiated, we fire an synchronous GET call to a .Net Core WebAPI installed on IIS on my local machine (localhost) to load some configuration data.
This DLL makes use of a singleton HttpClient (we've following Microsoft's 'best practices' here)
Factory.SingletonHttpClient().GetAsync(args.Uri).GetAwaiter().GetResult();
I've consumed this NuGet package in a whole series of applications, all built using .Net Framework 4.7.2 and they work just fine - the data is successfully retrieved from the WebAPI.
However....I have one particular application (again, 4.7.2) where the GET consistently fails with the error message:
System.Net.Sockets.SocketException HResult=0x80004005 Message=An
existing connection was forcibly closed by the remote host
This exception was originally thrown at this call stack:
System.Net.Sockets.Socket.BeginReceive(byte[], int, int, System.Net.Sockets.SocketFlags, System.AsyncCallback, object)
So this has to be something specific to my application that consumes this NuGet package since it works for all other consuming applications. However, I can't see how to figure out what the problem might be.

So I found the answer, but I'm confused by it.
I'm using the latest version of Windows 10 (version 1909).
All my applications are using .Net 4.7.2
So when I debug all these .NET 4.7.2 applications on my machine, they all make the call to the WebAPI on my IIS LocalHost, except this one application.
When I look at the ServicePointManager.SecurityProtocol in this failing application, I see it's running with the obsolete values of SSL and TLS. Why would this be the case for this application but not the others? It's not stipulated anywhere to use these obsolete protocols, so why is this using them but not the other applications?
I fixed this by amending my NuGet DLL to add TLS1.2 to whatever TLS versions are being used:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | ServicePointManager.SecurityProtocol;

Related

Upgrade .NET Framework 4.5 to 4.8 - Web Application Returning 404 Error

I have attempting to upgrade a web application that uses .NET Framework 4.5 to 4.8.
The application runs on a server that both compiles and runs the application, so I installed the .NET Framework 4.8 Developer Pack. I restarted the server and it has booted up successfully.
TeamCity successfully built and compiled the application and Octopus successfully deployed as per usual. However, when I now attempt to access the website, I get a 404 at the login page.
Looking at the folder structure, the file is definitely there. The code builds and runs successfully on my local machine, allowing me to login and perform any function on the system.
Is there something that I have missed running or doing on the server to get this to work?
Edit: Request for IIS Configuration
The configuration of this hasn't changed since I've upgrade the .NET Framework but here is what I have. If this isn't the configuration that is being asked about, please let me know.
Bindings
Everything else has been left as the default values.

HTTP Error 500.19 - Internal Server Error web config .net core web api

Detailed Error Information:
Module:
IIS Web Core
Notification:
BeginRequest
Handler:
Not yet determined
Error Code:
0x8007000d
Config Error:
Config File:
\?\C:\inetpub\wwwroot\webapi\web.config
can you help me?
I had similar challenge with an aspnet.core web application. I took these steps
1. I installed the Windows Server Hosting (.exe) from https://www.microsoft.com/net/download/windows
2. I granted full permission to the application directory
Hope this solved your problem
I had this same error, but different fix in case it helps someone. I thought sure that I had installed the .NET Core Runtime on the server. Turns out it wasn't actually there. Another sign that it's not installed is that in IIS Administrator, at the machine node, the Modules panel does not have the AspNetCoreModule registered (and indeed there was no aspnetcore.dll at \System32\inetsrv). Once I installed the .NET Core Runtime and restarted IIS, the application worked.
Another tip: installing the .NET Core SDK does not install the runtime components, including for IIS hosting. You must install specifically the Runtime to support apps on IIS.

.net xAPI not working in Unity

I've downloaded the .NET xAPI from here: https://github.com/RusticiSoftware/TinCanAPILibraryCSharp
When I test the code in console mode I am able to make a connection with both my local server and public lrs: http://tincanapi.com/public-lrs/
However, when I run that same code from Unity, I can only make a connection with my local server, I can no longer connect with the public lrs or any other remote server for that matter, I keep getting "no internet connection" and nothing else.
Any ideas on what this could be??
Currently and if i m right, running dlls compiled with .NET frameworks > 3.5 on unity3d can be a problem. Considering tin can is newly released... Maybe your problem is related?
If you create the dll yourself, be sure to focus on .Net framework 3.5

.NET Framework Method Not Found 'Void System.GC.Collect'

I'm trying to run some service and I'm getting this message
Method not found: 'Void System.GC.Collect(Int32,
System.GCCollectionMode)'
I suspect the server because this service runs on other servers.
I really want to know what the source of this problem because I came across this problem on other servers.
I try to take of code from my service and finally I realized that even I run a console application with only one static main and call the GC I get this error,
I'm using Windows Server 2003 with Framework 2.0 and 3.5
When you create your console application make sure your target framework is not set to Client Profile FrameWork 3.5.
The above setting is in Application tab of your project properties
If you want to use GCCollectionMode and Framework 2.0 you will have to install .NET 2.0 Service Pack 1

ASP.NET Ajax client framework failed to load

We developed an web application using visual studio 2008. In my development PC, the application is working fine. In production server I am getting the following exception "ASP.NET AJAX CLIENT FRAMEWORK FAILED TO LOAD". What should I do to make it work?
Thanks,
P.Gopalakrishnan.
I'd start with making sure all of the appropriate service packs are applied and that the 3.5 framework is actually installed on the box.
Also, make sure any assembly you reference that isn't part of your deployment is gac'd on the machine. Check version numbers.
All else being equal, I'd guess the server is just way out of date on it's updates.