I have Windows Service and ASP.NET application. Both the applications are sharing the same .Net Library that is internally using HttpClient
class to make GET and POST request.
When Windows Service is making the GET call via shared library, then i dont get any exception. However when ASP.NET make the GET call via the same shared library i am getting the following exception.
Timestamp: 11/1/2017 4:55:23 PM
Message: Message: One or more errors occurred. Type: AggregateException Stack Trace: at System.Threading.Tasks.Task
1.GetResultCore(Boolean waitCompletionNotification) at MyCompany.SharedLib.CFGetRequest(String params, Int32 attempt) at MyCompany.SharedLib.Pause(String apiKey, Int32 jobId) at MyCompany.Domain.Services.LabDomainService.Pause(Detail detail, String apiKey) in d:\Jenkins\XXXXXX.cs:line 189 at MyCompany.Domain.Services.LabDomainService.Pause(Int32 id) in d:\Jenkins\XXXXXX.cs:line 101 at MyCompany.UI.Controllers.HomeController.Pause(Int32 id) in d:\Jenkins\XXXXX:line 135 at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary
2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult
2.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.b__3d() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.b__1c() at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.b__1e(IAsyncResult asyncResult)Inner Exception Message: An error occurred while sending the request. Type: HttpRequestException Inner Exception Stack Trace:
Inner Exception Message: The underlying connection was closed: An unexpected error occurred on a send. Type: WebException Inner Exception Stack Trace: at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)Inner Exception Message: Authentication failed because the remote party has closed the transport stream. Type: IOException Inner Exception Stack Trace: at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult) at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)
Category: General
Priority: -1
EventId: 0
Severity: Error
Title:
Machine: WIN-T49H73AEU41
App Domain: /LM/W3SVC/3/ROOT-3-131540289107739161
ProcessId: 26596
Process Name: c:\windows\system32\inetsrv\w3wp.exe
Thread Name:
Win32 ThreadId:30164
Background
We started getting this exception recently in both the applications, so based on research we update the Target framework from 4.5
to 4.6.2
so applications can use TLS1.2 version. After upgrading the target framework windows service is working fine however ASP.NET application is still throws above exception
Does HttpClient
use different default System.Net.ServicePointManager.SecurityProtocol
in Widows Service vs in ASP.NET