dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.28k stars 4.73k forks source link

HTTP POST and PUT requests fail with "The response ended prematurely" #98177

Closed mu88 closed 9 months ago

mu88 commented 9 months ago

Is there an existing issue for this?

Describe the bug

When running an HTTP POST or HTTP PUT request using the HttpClient against an ASP.NET Core Web API, it fails with the following exception:

System.Net.Http.HttpRequestException: An error occurred while sending the request.

System.Net.Http.HttpRequestException
An error occurred while sending the request.
   at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)

System.IO.IOException
The response ended prematurely.
   at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)

This only happens under the following circumstances:

These requests only fail when using the HttpClient in C#, but they succeed when running them via...

Expected Behavior

The HTTP PUT and POST requests do not fail.

Steps To Reproduce

  1. Clone this repository: https://github.com/mu88/Repro_HttpClient_POST_fails
  2. Open the *.sln
  3. Start the WebApi project
  4. Run the tests

In my case, the test result looks like this:
image

When checking the WebApi logs, I see that the backend seems to handle the requests properly - at least I always see a 2xx status code:

ASP.NET Core Logs (details dropdown) ``` info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: POST Scheme: http PathBase: Path: /api/processor/process Host: localhost:5254 Content-Type: application/json; charset=utf-8 Content-Length: 50 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 204 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: PUT Scheme: http PathBase: Path: /api/processor/process Host: localhost:5254 Content-Type: application/json; charset=utf-8 Content-Length: 50 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 204 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: GET Scheme: http PathBase: Path: /api/processor/hello Host: localhost:5254 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 200 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: DELETE Scheme: http PathBase: Path: /api/processor/goodbye Host: localhost:5254 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 200 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: POST Scheme: http PathBase: Path: /internal-api/dataset/complete Host: localhost:5254 Content-Length: 0 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 204 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: POST Scheme: http PathBase: Path: /internal-api/dataset/complete Host: localhost:5254 Content-Length: 0 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 204 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: POST Scheme: http PathBase: Path: /internal-api/dataset/complete Host: localhost:5254 Content-Length: 0 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 204 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: POST Scheme: http PathBase: Path: /internal-api/dataset/complete Host: localhost:5254 Content-Length: 0 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 204 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: POST Scheme: http PathBase: Path: /internal-api/dataset/complete Host: localhost:5254 Content-Type: text/plain; charset=utf-8 Content-Length: 0 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 204 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: PUT Scheme: http PathBase: Path: /api/processor/process Host: localhost:5254 Content-Type: application/json; charset=utf-8 Transfer-Encoding: chunked info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: POST Scheme: http PathBase: Path: /api/processor/process Host: localhost:5254 Content-Type: application/json; charset=utf-8 Transfer-Encoding: chunked info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 200 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 200 ```

The tests are only used for easier usage. Instead, the CLI project Client can be used as well and triggers the same exceptions.

Exceptions (if any)

System.Net.Http.HttpRequestException: An error occurred while sending the request.

System.Net.Http.HttpRequestException
An error occurred while sending the request.
   at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
   at Client.Helper.CompleteViaPostWithEmptyAsync(HttpClient httpClient) in C:\work\GitHub\Repro_HttpClient_POST_fails\Client\Helper.cs:line 49

System.IO.IOException
The response ended prematurely.
   at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)

.NET Version

8.0.101

Anything else?

Additional information

Dotnet info ``` .NET SDK: Version: 8.0.101 Commit: 6eceda187b Workload version: 8.0.100-manifests.f64b8c85 Runtime Environment: OS Name: Windows OS Version: 10.0.19045 OS Platform: Windows RID: win-x64 Base Path: C:\Program Files\dotnet\sdk\8.0.101\ .NET workloads installed: Workload version: 8.0.100-manifests.f64b8c85 [maui-maccatalyst] Installation Source: SDK 8.0.100 Manifest Version: 8.0.3/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.3\WorkloadManifest.json Install Type: Msi [maui-tizen] Installation Source: SDK 8.0.100 Manifest Version: 8.0.3/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.3\WorkloadManifest.json Install Type: Msi [maui-windows] Installation Source: VS 17.8.34408.163 Manifest Version: 8.0.3/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.3\WorkloadManifest.json Install Type: Msi [maccatalyst] Installation Source: VS 17.8.34408.163 Manifest Version: 17.0.8490/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maccatalyst\17.0.8490\WorkloadManifest.json Install Type: Msi [ios] Installation Source: VS 17.8.34408.163 Manifest Version: 17.0.8490/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.ios\17.0.8490\WorkloadManifest.json Install Type: Msi [android] Installation Source: VS 17.8.34408.163 Manifest Version: 34.0.52/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.android\34.0.52\WorkloadManifest.json Install Type: Msi Host: Version: 8.0.1 Architecture: x64 Commit: bf5e279d92 .NET SDKs installed: 2.1.700 [C:\Program Files\dotnet\sdk] 2.2.300 [C:\Program Files\dotnet\sdk] 8.0.101 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Other architectures found: x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation] Environment variables: Not set global.json file: Not found ```

Broader context

Of course, this is a rather simplified example. In our team, we're maintaining a dozen of different apps following the same pattern which is similar to the shown example. Since we set great store by testing, we have a lot of system integration tests where we test our ASP.NET Core Web API (which is running in Docker) via HttpClient.

Since I got a new laptop, I installed all the necessary pieces (Git, .NET SDK, Docker Desktop, etc.) and cloned several of our apps. I can run all unit and integration tests, but some of the system integration tests fail. It took me a long time to remove the complexity step by step until I noticed that only those tests fail which make use HTTP POST or PUT using the HttpClient. So I further removed different layers (Docker, xUnit) and reduced it down to a dumb CLI app using the HttpClient to access an ASP.NET Core Web API - the result is the repro repo https://github.com/mu88/Repro_HttpClient_POST_fails.

❗ So at the moment, I'm not able to run any of our system integration tests that make use of HTTP POST or PUT. Therefore, this bug has a certain impact on my inner dev loop and I'd appreciate it if you could have a look.
I'm fully aware that you (as my colleagues) probably won't be able to reproduce the problem. However, I hope that you can give me some guidance on what to analyze. Thanks in advance!

Tratcher commented 9 months ago

Turn the server logs all up to Debug level and see why the response is truncated.

mu88 commented 9 months ago

This is the updated logging config:

{
  "Logging": {
    "LogLevel": {
      "Default": "Debug",
      "Microsoft.AspNetCore": "Debug",
      "Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware": "Debug"
    }
  }
}

And this is the log output when running the app in Development mode for the request HTTP POST api/processor/process:

Logs ``` dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[39] Connection id "0HN17LC47KFOU" accepted. dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[1] Connection id "0HN17LC47KFOU" started. info: Microsoft.AspNetCore.Hosting.Diagnostics[1] Request starting HTTP/1.1 POST http://localhost:5254/api/processor/process application/json;+charset=utf-8 - info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: POST Scheme: http PathBase: Path: /api/processor/process Host: localhost:5254 Content-Type: application/json; charset=utf-8 Transfer-Encoding: chunked dbug: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[1] POST requests are not supported dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1001] 1 candidate(s) found for the request path '/api/processor/process' dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1005] Endpoint 'WebApi.ProcessorController.ProcessAsPostAsync (WebApi)' with route pattern 'api/processor/process' is valid for the request path '/api/processor/process' dbug: Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware[1] Request matched endpoint 'WebApi.ProcessorController.ProcessAsPostAsync (WebApi)' info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0] Executing endpoint 'WebApi.ProcessorController.ProcessAsPostAsync (WebApi)' info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[102] Route matched with {action = "ProcessAsPost", controller = "Processor"}. Executing controller action with signature System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] ProcessAsPost Async(WebApi.RunJobCommand, System.Threading.CancellationToken) on controller WebApi.ProcessorController (WebApi). dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of authorization filters (in the following order): None dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of resource filters (in the following order): None dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of action filters (in the following order): Microsoft.AspNetCore.Mvc.ModelBinding.UnsupportedContentTypeFilter (Order: -3000), Microsoft.AspNetCore.Mvc.Infrastructure.ModelStateInvalid Filter (Order: -2000) dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of exception filters (in the following order): None dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of result filters (in the following order): Microsoft.AspNetCore.Mvc.Infrastructure.ClientErrorResultFilter (Order: -2000) dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Executing controller factory for controller WebApi.ProcessorController (WebApi) dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[2] Executed controller factory for controller WebApi.ProcessorController (WebApi) dbug: Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder[22] Attempting to bind parameter 'runJobCommand' of type 'WebApi.RunJobCommand' ... dbug: Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinder[44] Attempting to bind parameter 'runJobCommand' of type 'WebApi.RunJobCommand' using the name '' in request data ... dbug: Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinder[1] Selected input formatter 'Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonInputFormatter' for content type 'application/json; charset=utf-8'. dbug: Microsoft.AspNetCore.Server.Kestrel[25] Connection id "0HN17LC47KFOU", Request id "0HN17LC47KFOU:00000001": started reading request body. dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[6] Connection id "0HN17LC47KFOU" received FIN. dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[7] Connection id "0HN17LC47KFOU" sending FIN because: "The Socket transport's send loop completed gracefully." dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[10] Connection id "0HN17LC47KFOU" disconnecting. info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[105] Executed action WebApi.ProcessorController.ProcessAsPostAsync (WebApi) in 20170.0086ms info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1] Executed endpoint 'WebApi.ProcessorController.ProcessAsPostAsync (WebApi)' fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1] An unhandled exception has occurred while executing the request. Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Unexpected end of request content. at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ChunkedEncodingMessageBody.PumpAsync() at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result) at System.IO.Pipelines.Pipe.GetReadAsyncResult() at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ChunkedEncodingMessageBody.ReadAsyncInternal(CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.ReadAsyncInternal(Memory`1 destination, CancellationToken cancellationToken) at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at System.Text.Json.Serialization.ReadBufferState.ReadFromStreamAsync(Stream utf8Json, CancellationToken cancellationToken, Boolean fillBuffer) at System.Text.Json.JsonSerializer.ReadFromStreamAsync[TValue](Stream utf8Json, JsonTypeInfo jsonTypeInfo, CancellationToken cancellationToken) at Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonInputFormatter.ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding) at Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonInputFormatter.ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding) at Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinder.BindModelAsync(ModelBindingContext bindingContext) at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMet adata metadata, Object value, Object container) at Microsoft.AspNetCore.Mvc.Controllers.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<g__Bind|0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Bo olean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompl eted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware.InvokeInternal(HttpContext context) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context) info: Microsoft.AspNetCore.Hosting.Diagnostics[2] Request finished HTTP/1.1 POST http://localhost:5254/api/processor/process application/json;+charset=utf-8 - - 400 - text/plain;+charset=utf-8 20578.5588ms dbug: Microsoft.AspNetCore.Server.Kestrel[26] Connection id "0HN17LC47KFOU", Request id "0HN17LC47KFOU:00000001": done reading request body. dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[2] Connection id "0HN17LC47KFOU" stopped. ``` And here's the output for the same request when setting `ASPNETCORE_ENVIRONMENT` to `Production`: ``` dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[39] Connection id "0HN17LFLU5H87" accepted. dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[1] Connection id "0HN17LFLU5H87" started. info: Microsoft.AspNetCore.Hosting.Diagnostics[1] Request starting HTTP/1.1 POST http://localhost:5254/api/processor/process application/json;+charset=utf-8 - dbug: Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware[0] Wildcard detected, all requests with hosts will be allowed. info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: POST Scheme: http PathBase: Path: /api/processor/process Host: localhost:5254 Content-Type: application/json; charset=utf-8 Transfer-Encoding: chunked dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1001] 1 candidate(s) found for the request path '/api/processor/process' dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1005] Endpoint 'WebApi.ProcessorController.ProcessAsPostAsync (WebApi)' with route pattern 'api/processor/process' is valid for the request path '/api/processor/process' dbug: Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware[1] Request matched endpoint 'WebApi.ProcessorController.ProcessAsPostAsync (WebApi)' info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0] Executing endpoint 'WebApi.ProcessorController.ProcessAsPostAsync (WebApi)' info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[102] Route matched with {action = "ProcessAsPost", controller = "Processor"}. Executing controller action with signature System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] ProcessAsPost Async(WebApi.RunJobCommand, System.Threading.CancellationToken) on controller WebApi.ProcessorController (WebApi). dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of authorization filters (in the following order): None dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of resource filters (in the following order): None dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of action filters (in the following order): Microsoft.AspNetCore.Mvc.ModelBinding.UnsupportedContentTypeFilter (Order: -3000), Microsoft.AspNetCore.Mvc.Infrastructure.ModelStateInvalid Filter (Order: -2000) dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of exception filters (in the following order): None dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of result filters (in the following order): Microsoft.AspNetCore.Mvc.Infrastructure.ClientErrorResultFilter (Order: -2000) dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Executing controller factory for controller WebApi.ProcessorController (WebApi) dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[2] Executed controller factory for controller WebApi.ProcessorController (WebApi) dbug: Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder[22] Attempting to bind parameter 'runJobCommand' of type 'WebApi.RunJobCommand' ... dbug: Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinder[44] Attempting to bind parameter 'runJobCommand' of type 'WebApi.RunJobCommand' using the name '' in request data ... dbug: Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinder[1] Selected input formatter 'Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonInputFormatter' for content type 'application/json; charset=utf-8'. dbug: Microsoft.AspNetCore.Server.Kestrel[25] Connection id "0HN17LFLU5H87", Request id "0HN17LFLU5H87:00000001": started reading request body. dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[6] Connection id "0HN17LFLU5H87" received FIN. dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[7] Connection id "0HN17LFLU5H87" sending FIN because: "The Socket transport's send loop completed gracefully." dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[10] Connection id "0HN17LFLU5H87" disconnecting. info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[105] Executed action WebApi.ProcessorController.ProcessAsPostAsync (WebApi) in 20656.9192ms info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1] Executed endpoint 'WebApi.ProcessorController.ProcessAsPostAsync (WebApi)' dbug: Microsoft.AspNetCore.Server.Kestrel.BadRequests[17] Connection id "0HN17LFLU5H87" bad request data: "Unexpected end of request content." Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Unexpected end of request content. at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ChunkedEncodingMessageBody.PumpAsync() at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result) at System.IO.Pipelines.Pipe.GetReadAsyncResult() at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ChunkedEncodingMessageBody.ReadAsyncInternal(CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.ReadAsyncInternal(Memory`1 destination, CancellationToken cancellationToken) at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at System.Text.Json.Serialization.ReadBufferState.ReadFromStreamAsync(Stream utf8Json, CancellationToken cancellationToken, Boolean fillBuffer) at System.Text.Json.JsonSerializer.ReadFromStreamAsync[TValue](Stream utf8Json, JsonTypeInfo jsonTypeInfo, CancellationToken cancellationToken) at Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonInputFormatter.ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding) at Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonInputFormatter.ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding) at Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinder.BindModelAsync(ModelBindingContext bindingContext) at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMet adata metadata, Object value, Object container) at Microsoft.AspNetCore.Mvc.Controllers.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<g__Bind|0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Bo olean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompl eted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware.InvokeInternal(HttpContext context) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application) fail: Microsoft.AspNetCore.Server.Kestrel[13] Connection id "0HN17LFLU5H87", Request id "0HN17LFLU5H87:00000001": An unhandled exception was thrown by the application. Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Unexpected end of request content. at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ChunkedEncodingMessageBody.PumpAsync() at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result) at System.IO.Pipelines.Pipe.GetReadAsyncResult() at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ChunkedEncodingMessageBody.ReadAsyncInternal(CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.ReadAsyncInternal(Memory`1 destination, CancellationToken cancellationToken) at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at System.Text.Json.Serialization.ReadBufferState.ReadFromStreamAsync(Stream utf8Json, CancellationToken cancellationToken, Boolean fillBuffer) at System.Text.Json.JsonSerializer.ReadFromStreamAsync[TValue](Stream utf8Json, JsonTypeInfo jsonTypeInfo, CancellationToken cancellationToken) at Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonInputFormatter.ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding) at Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonInputFormatter.ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding) at Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinder.BindModelAsync(ModelBindingContext bindingContext) at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMet adata metadata, Object value, Object container) at Microsoft.AspNetCore.Mvc.Controllers.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<g__Bind|0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Bo olean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompl eted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware.InvokeInternal(HttpContext context) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application) info: Microsoft.AspNetCore.Hosting.Diagnostics[2] Request finished HTTP/1.1 POST http://localhost:5254/api/processor/process application/json;+charset=utf-8 - - 400 0 - 21370.2804ms dbug: Microsoft.AspNetCore.Server.Kestrel[26] Connection id "0HN17LFLU5H87", Request id "0HN17LFLU5H87:00000001": done reading request body. dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[2] Connection id "0HN17LFLU5H87" stopped. ```
Tratcher commented 9 months ago

Huh, those error messages don't line up. The server says the client ended the connection before it finished sending the request body. The client says the server ended the connection before it finished sending the response. I suspect this is a client issue but we'll need wireshark traces to confirm. Connection level logs would also work. https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel/connection-middleware?view=aspnetcore-8.0#connection-logging

Tratcher commented 9 months ago

@MihaZupan

mu88 commented 9 months ago

I've added the following code to configure the connection logging:

builder.WebHost.ConfigureKestrel((_, serverOptions) =>
{
    serverOptions.Listen(IPAddress.Any, 5254, listenOptions =>
    {
        listenOptions.UseConnectionLogging();
    });
});

And here's the output for HTTP POST api/processor/process via .PostAsJsonAsync:

Logs for PostAsJsonAsync ``` dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[39] Connection id "0HN18E1BP09CE" accepted. dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[1] Connection id "0HN18E1BP09CE" started. dbug: Microsoft.AspNetCore.Server.Kestrel.Core.Internal.LoggingConnectionMiddleware[0] ReadAsync[137] 50 4F 53 54 20 2F 61 70 69 2F 70 72 6F 63 65 73 POST /ap i/proces 73 6F 72 2F 70 72 6F 63 65 73 73 20 48 54 54 50 sor/proc ess HTTP 2F 31 2E 31 0D 0A 48 6F 73 74 3A 20 6C 6F 63 61 /1.1..Ho st: loca 6C 68 6F 73 74 3A 35 32 35 34 0D 0A 54 72 61 6E lhost:52 54..Tran 73 66 65 72 2D 45 6E 63 6F 64 69 6E 67 3A 20 63 sfer-Enc oding: c 68 75 6E 6B 65 64 0D 0A 43 6F 6E 74 65 6E 74 2D hunked.. Content- 54 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F Type: ap plicatio 6E 2F 6A 73 6F 6E 3B 20 63 68 61 72 73 65 74 3D n/json; charset= 75 74 66 2D 38 0D 0A 0D 0A utf-8... . info: Microsoft.AspNetCore.Hosting.Diagnostics[1] Request starting HTTP/1.1 POST http://localhost:5254/api/processor/process application/json;+charset=utf-8 - dbug: Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware[0] Wildcard detected, all requests with hosts will be allowed. info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: POST Scheme: http PathBase: Path: /api/processor/process Host: localhost:5254 Content-Type: application/json; charset=utf-8 Transfer-Encoding: chunked dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1001] 1 candidate(s) found for the request path '/api/processor/process' dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1005] Endpoint 'WebApi.ProcessorController.ProcessAsPostAsync (WebApi)' with route pattern 'api/processor/process' is valid for the request path '/api/processor/process' dbug: Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware[1] Request matched endpoint 'WebApi.ProcessorController.ProcessAsPostAsync (WebApi)' info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0] Executing endpoint 'WebApi.ProcessorController.ProcessAsPostAsync (WebApi)' info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[102] Route matched with {action = "ProcessAsPost", controller = "Processor"}. Executing controller action with signature System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] Pro cessAsPostAsync(WebApi.RunJobCommand, System.Threading.CancellationToken) on controller WebApi.ProcessorController (WebApi). dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of authorization filters (in the following order): None dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of resource filters (in the following order): None dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of action filters (in the following order): Microsoft.AspNetCore.Mvc.ModelBinding.UnsupportedContentTypeFilter (Order: -3000), Microsoft.AspNetCore.Mvc.Infrastructure.ModelSt ateInvalidFilter (Order: -2000) dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of exception filters (in the following order): None dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of result filters (in the following order): Microsoft.AspNetCore.Mvc.Infrastructure.ClientErrorResultFilter (Order: -2000) dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Executing controller factory for controller WebApi.ProcessorController (WebApi) dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[2] Executed controller factory for controller WebApi.ProcessorController (WebApi) dbug: Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder[22] Attempting to bind parameter 'runJobCommand' of type 'WebApi.RunJobCommand' ... dbug: Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinder[44] Attempting to bind parameter 'runJobCommand' of type 'WebApi.RunJobCommand' using the name '' in request data ... dbug: Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinder[1] Selected input formatter 'Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonInputFormatter' for content type 'application/json; charset=utf-8'. dbug: Microsoft.AspNetCore.Server.Kestrel[25] Connection id "0HN18E1BP09CE", Request id "0HN18E1BP09CE:00000001": started reading request body. dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[6] Connection id "0HN18E1BP09CE" received FIN. dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[7] Connection id "0HN18E1BP09CE" sending FIN because: "The Socket transport's send loop completed gracefully." dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[10] Connection id "0HN18E1BP09CE" disconnecting. dbug: Microsoft.AspNetCore.Server.Kestrel.Core.Internal.LoggingConnectionMiddleware[0] ReadAsync[0] info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[105] Executed action WebApi.ProcessorController.ProcessAsPostAsync (WebApi) in 20066.6444ms info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1] Executed endpoint 'WebApi.ProcessorController.ProcessAsPostAsync (WebApi)' dbug: Microsoft.AspNetCore.Server.Kestrel.BadRequests[17] Connection id "0HN18E1BP09CE" bad request data: "Unexpected end of request content." Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Unexpected end of request content. at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ChunkedEncodingMessageBody.PumpAsync() at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result) at System.IO.Pipelines.Pipe.GetReadAsyncResult() at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ChunkedEncodingMessageBody.ReadAsyncInternal(CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.ReadAsyncInternal(Memory`1 destination, CancellationToken cancellationToken) at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at System.Text.Json.Serialization.ReadBufferState.ReadFromStreamAsync(Stream utf8Json, CancellationToken cancellationToken, Boolean fillBuffer) at System.Text.Json.JsonSerializer.ReadFromStreamAsync[TValue](Stream utf8Json, JsonTypeInfo jsonTypeInfo, CancellationToken cancellationToken) at Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonInputFormatter.ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding) at Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonInputFormatter.ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding) at Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinder.BindModelAsync(ModelBindingContext bindingContext) at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter , ModelMetadata metadata, Object value, Object container) at Microsoft.AspNetCore.Mvc.Controllers.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<g__Bind|0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boole an isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware.InvokeInternal(HttpContext context) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application) fail: Microsoft.AspNetCore.Server.Kestrel[13] Connection id "0HN18E1BP09CE", Request id "0HN18E1BP09CE:00000001": An unhandled exception was thrown by the application. Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Unexpected end of request content. at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ChunkedEncodingMessageBody.PumpAsync() at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result) at System.IO.Pipelines.Pipe.GetReadAsyncResult() at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ChunkedEncodingMessageBody.ReadAsyncInternal(CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.ReadAsyncInternal(Memory`1 destination, CancellationToken cancellationToken) at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at System.Text.Json.Serialization.ReadBufferState.ReadFromStreamAsync(Stream utf8Json, CancellationToken cancellationToken, Boolean fillBuffer) at System.Text.Json.JsonSerializer.ReadFromStreamAsync[TValue](Stream utf8Json, JsonTypeInfo jsonTypeInfo, CancellationToken cancellationToken) at Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonInputFormatter.ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding) at Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonInputFormatter.ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding) at Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinder.BindModelAsync(ModelBindingContext bindingContext) at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter , ModelMetadata metadata, Object value, Object container) at Microsoft.AspNetCore.Mvc.Controllers.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<g__Bind|0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boole an isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware.InvokeInternal(HttpContext context) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application) info: Microsoft.AspNetCore.Hosting.Diagnostics[2] Request finished HTTP/1.1 POST http://localhost:5254/api/processor/process application/json;+charset=utf-8 - - 400 0 - 20540.2393ms dbug: Microsoft.AspNetCore.Server.Kestrel[26] Connection id "0HN18E1BP09CE", Request id "0HN18E1BP09CE:00000001": done reading request body. dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[2] Connection id "0HN18E1BP09CE" stopped. ```

And the output for the same request via .PostAsync (which succeeds):

Logs for PostAsync ``` dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[39] Connection id "0HN18E750JR7D" accepted. dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[1] Connection id "0HN18E750JR7D" started. dbug: Microsoft.AspNetCore.Server.Kestrel.Core.Internal.LoggingConnectionMiddleware[0] ReadAsync[179] 50 4F 53 54 20 2F 61 70 69 2F 70 72 6F 63 65 73 POST /ap i/proces 73 6F 72 2F 70 72 6F 63 65 73 73 20 48 54 54 50 sor/proc ess HTTP 2F 31 2E 31 0D 0A 48 6F 73 74 3A 20 6C 6F 63 61 /1.1..Ho st: loca 6C 68 6F 73 74 3A 35 32 35 34 0D 0A 43 6F 6E 74 lhost:52 54..Cont 65 6E 74 2D 54 79 70 65 3A 20 61 70 70 6C 69 63 ent-Type : applic 61 74 69 6F 6E 2F 6A 73 6F 6E 3B 20 63 68 61 72 ation/js on; char 73 65 74 3D 75 74 66 2D 38 0D 0A 43 6F 6E 74 65 set=utf- 8..Conte 6E 74 2D 4C 65 6E 67 74 68 3A 20 35 30 0D 0A 0D nt-Lengt h: 50... 0A 7B 22 4A 6F 62 49 64 65 6E 74 69 66 69 65 72 .{"JobId entifier 22 3A 20 22 6D 75 38 38 22 2C 20 22 43 6F 6E 66 ": "mu88 ", "Conf 69 72 6D 4A 6F 62 53 74 61 72 74 22 3A 20 74 72 irmJobSt art": tr 75 65 7D ue} info: Microsoft.AspNetCore.Hosting.Diagnostics[1] Request starting HTTP/1.1 POST http://localhost:5254/api/processor/process application/json;+charset=utf-8 50 dbug: Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware[0] Wildcard detected, all requests with hosts will be allowed. info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: POST Scheme: http PathBase: Path: /api/processor/process Host: localhost:5254 Content-Type: application/json; charset=utf-8 Content-Length: 50 dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1001] 1 candidate(s) found for the request path '/api/processor/process' dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1005] Endpoint 'WebApi.ProcessorController.ProcessAsPostAsync (WebApi)' with route pattern 'api/processor/process' is valid for the request path '/api/processor/process' dbug: Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware[1] Request matched endpoint 'WebApi.ProcessorController.ProcessAsPostAsync (WebApi)' info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0] Executing endpoint 'WebApi.ProcessorController.ProcessAsPostAsync (WebApi)' info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[102] Route matched with {action = "ProcessAsPost", controller = "Processor"}. Executing controller action with signature System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] ProcessA sPostAsync(WebApi.RunJobCommand, System.Threading.CancellationToken) on controller WebApi.ProcessorController (WebApi). dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of authorization filters (in the following order): None dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of resource filters (in the following order): None dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of action filters (in the following order): Microsoft.AspNetCore.Mvc.ModelBinding.UnsupportedContentTypeFilter (Order: -3000), Microsoft.AspNetCore.Mvc.Infrastructure.ModelStateIn validFilter (Order: -2000) dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of exception filters (in the following order): None dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of result filters (in the following order): Microsoft.AspNetCore.Mvc.Infrastructure.ClientErrorResultFilter (Order: -2000) dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Executing controller factory for controller WebApi.ProcessorController (WebApi) dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[2] Executed controller factory for controller WebApi.ProcessorController (WebApi) dbug: Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder[22] Attempting to bind parameter 'runJobCommand' of type 'WebApi.RunJobCommand' ... dbug: Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinder[44] Attempting to bind parameter 'runJobCommand' of type 'WebApi.RunJobCommand' using the name '' in request data ... dbug: Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinder[1] Selected input formatter 'Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonInputFormatter' for content type 'application/json; charset=utf-8'. dbug: Microsoft.AspNetCore.Server.Kestrel[25] Connection id "0HN18E750JR7D", Request id "0HN18E750JR7D:00000001": started reading request body. dbug: Microsoft.AspNetCore.Server.Kestrel[26] Connection id "0HN18E750JR7D", Request id "0HN18E750JR7D:00000001": done reading request body. dbug: Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonInputFormatter[2] JSON input formatter succeeded, deserializing to type 'WebApi.RunJobCommand' dbug: Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinder[45] Done attempting to bind parameter 'runJobCommand' of type 'WebApi.RunJobCommand'. dbug: Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder[23] Done attempting to bind parameter 'runJobCommand' of type 'WebApi.RunJobCommand'. dbug: Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder[26] Attempting to validate the bound parameter 'runJobCommand' of type 'WebApi.RunJobCommand' ... dbug: Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder[27] Done attempting to validate the bound parameter 'runJobCommand' of type 'WebApi.RunJobCommand'. dbug: Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder[22] Attempting to bind parameter 'httpRequestCancellationToken' of type 'System.Threading.CancellationToken' ... dbug: Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder[23] Done attempting to bind parameter 'httpRequestCancellationToken' of type 'System.Threading.CancellationToken'. dbug: Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder[26] Attempting to validate the bound parameter 'httpRequestCancellationToken' of type 'System.Threading.CancellationToken' ... dbug: Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder[27] Done attempting to validate the bound parameter 'httpRequestCancellationToken' of type 'System.Threading.CancellationToken'. info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[101] Executing action method WebApi.ProcessorController.ProcessAsPostAsync (WebApi) - Validation state: Valid info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[103] Executed action method WebApi.ProcessorController.ProcessAsPostAsync (WebApi), returned result Microsoft.AspNetCore.Mvc.NoContentResult in 1005.3392ms. info: Microsoft.AspNetCore.Mvc.StatusCodeResult[1] Executing StatusCodeResult, setting HTTP status code 204 info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[105] Executed action WebApi.ProcessorController.ProcessAsPostAsync (WebApi) in 1069.9517ms info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1] Executed endpoint 'WebApi.ProcessorController.ProcessAsPostAsync (WebApi)' info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 204 dbug: Microsoft.AspNetCore.Server.Kestrel.Core.Internal.LoggingConnectionMiddleware[0] WriteAsync[81] 48 54 54 50 2F 31 2E 31 20 32 30 34 20 4E 6F 20 HTTP/1.1 204 No 43 6F 6E 74 65 6E 74 0D 0A 44 61 74 65 3A 20 54 Content. .Date: T 68 75 2C 20 30 38 20 46 65 62 20 32 30 32 34 20 hu, 08 F eb 2024 30 36 3A 34 37 3A 31 37 20 47 4D 54 0D 0A 53 65 06:47:17 GMT..Se 72 76 65 72 3A 20 4B 65 73 74 72 65 6C 0D 0A 0D rver: Ke strel... 0A . dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[9] Connection id "0HN18E750JR7D" completed keep alive response. info: Microsoft.AspNetCore.Hosting.Diagnostics[2] Request finished HTTP/1.1 POST http://localhost:5254/api/processor/process application/json;+charset=utf-8 50 - 204 - - 1144.8163ms dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[6] Connection id "0HN18E750JR7D" received FIN. dbug: Microsoft.AspNetCore.Server.Kestrel.Core.Internal.LoggingConnectionMiddleware[0] ReadAsync[0] dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[7] Connection id "0HN18E750JR7D" sending FIN because: "The Socket transport's send loop completed gracefully." dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[10] Connection id "0HN18E750JR7D" disconnecting. dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[2] Connection id "0HN18E750JR7D" stopped. ```

One difference that I see (from a client-perspective) is that .PostAsJsonAsync chunks the request body whereas .PostAsync sends the complete request body at once.

mu88 commented 9 months ago

And here another log for the statement await httpClient.PostAsync("internal-api/dataset/complete", new StringContent(string.Empty), CancellationToken.None) which succeeds on the server but throws the mentioned exception on the client:

Logs ``` dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[39] Connection id "0HN18ED16VK05" accepted. dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[1] Connection id "0HN18ED16VK05" started. dbug: Microsoft.AspNetCore.Server.Kestrel.Core.Internal.LoggingConnectionMiddleware[0] ReadAsync[130] 50 4F 53 54 20 2F 69 6E 74 65 72 6E 61 6C 2D 61 POST /in ternal-a 70 69 2F 64 61 74 61 73 65 74 2F 63 6F 6D 70 6C pi/datas et/compl 65 74 65 20 48 54 54 50 2F 31 2E 31 0D 0A 48 6F ete HTTP /1.1..Ho 73 74 3A 20 6C 6F 63 61 6C 68 6F 73 74 3A 35 32 st: loca lhost:52 35 34 0D 0A 43 6F 6E 74 65 6E 74 2D 54 79 70 65 54..Cont ent-Type 3A 20 74 65 78 74 2F 70 6C 61 69 6E 3B 20 63 68 : text/p lain; ch 61 72 73 65 74 3D 75 74 66 2D 38 0D 0A 43 6F 6E arset=ut f-8..Con 74 65 6E 74 2D 4C 65 6E 67 74 68 3A 20 30 0D 0A tent-Len gth: 0.. 0D 0A .. info: Microsoft.AspNetCore.Hosting.Diagnostics[1] Request starting HTTP/1.1 POST http://localhost:5254/internal-api/dataset/complete text/plain;+charset=utf-8 0 dbug: Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware[0] Wildcard detected, all requests with hosts will be allowed. info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: POST Scheme: http PathBase: Path: /internal-api/dataset/complete Host: localhost:5254 Content-Type: text/plain; charset=utf-8 Content-Length: 0 dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1001] 1 candidate(s) found for the request path '/internal-api/dataset/complete' dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1005] Endpoint 'WebApi.DatasetController.ActivateAsync (WebApi)' with route pattern 'internal-api/dataset/complete' is valid for the request path '/internal-api/dataset/complete' dbug: Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware[1] Request matched endpoint 'WebApi.DatasetController.ActivateAsync (WebApi)' info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0] Executing endpoint 'WebApi.DatasetController.ActivateAsync (WebApi)' info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[102] Route matched with {action = "Activate", controller = "Dataset"}. Executing controller action with signature System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] ActivateAsync(S ystem.Threading.CancellationToken) on controller WebApi.DatasetController (WebApi). dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of authorization filters (in the following order): None dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of resource filters (in the following order): None dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of action filters (in the following order): Microsoft.AspNetCore.Mvc.ModelBinding.UnsupportedContentTypeFilter (Order: -3000), Microsoft.AspNetCore.Mvc.Infrastructure.ModelStateIn validFilter (Order: -2000) dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of exception filters (in the following order): None dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Execution plan of result filters (in the following order): Microsoft.AspNetCore.Mvc.Infrastructure.ClientErrorResultFilter (Order: -2000) dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1] Executing controller factory for controller WebApi.DatasetController (WebApi) dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[2] Executed controller factory for controller WebApi.DatasetController (WebApi) dbug: Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder[22] Attempting to bind parameter 'httpRequestCancellationToken' of type 'System.Threading.CancellationToken' ... dbug: Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder[23] Done attempting to bind parameter 'httpRequestCancellationToken' of type 'System.Threading.CancellationToken'. dbug: Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder[26] Attempting to validate the bound parameter 'httpRequestCancellationToken' of type 'System.Threading.CancellationToken' ... dbug: Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder[27] Done attempting to validate the bound parameter 'httpRequestCancellationToken' of type 'System.Threading.CancellationToken'. info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[101] Executing action method WebApi.DatasetController.ActivateAsync (WebApi) - Validation state: Valid info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[103] Executed action method WebApi.DatasetController.ActivateAsync (WebApi), returned result Microsoft.AspNetCore.Mvc.NoContentResult in 1008.04ms. info: Microsoft.AspNetCore.Mvc.StatusCodeResult[1] Executing StatusCodeResult, setting HTTP status code 204 info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[105] Executed action WebApi.DatasetController.ActivateAsync (WebApi) in 1063.4047ms info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1] Executed endpoint 'WebApi.DatasetController.ActivateAsync (WebApi)' info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 204 dbug: Microsoft.AspNetCore.Server.Kestrel.Core.Internal.LoggingConnectionMiddleware[0] WriteAsync[81] 48 54 54 50 2F 31 2E 31 20 32 30 34 20 4E 6F 20 HTTP/1.1 204 No 43 6F 6E 74 65 6E 74 0D 0A 44 61 74 65 3A 20 54 Content. .Date: T 68 75 2C 20 30 38 20 46 65 62 20 32 30 32 34 20 hu, 08 F eb 2024 30 36 3A 35 37 3A 34 39 20 47 4D 54 0D 0A 53 65 06:57:49 GMT..Se 72 76 65 72 3A 20 4B 65 73 74 72 65 6C 0D 0A 0D rver: Ke strel... 0A . dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[9] Connection id "0HN18ED16VK05" completed keep alive response. info: Microsoft.AspNetCore.Hosting.Diagnostics[2] Request finished HTTP/1.1 POST http://localhost:5254/internal-api/dataset/complete text/plain;+charset=utf-8 0 - 204 - - 1167.0587ms dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[19] Connection id "0HN18ED16VK05" reset. dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[7] Connection id "0HN18ED16VK05" sending FIN because: "The Socket transport's send loop completed gracefully." dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[10] Connection id "0HN18ED16VK05" disconnecting. dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[2] Connection id "0HN18ED16VK05" stopped. info: Microsoft.Hosting.Lifetime[0] Application is shutting down... dbug: Microsoft.Extensions.Hosting.Internal.Host[3] Hosting stopping dbug: Microsoft.Extensions.Hosting.Internal.Host[4] Hosting stopped ```
Tratcher commented 9 months ago

Yup, there's a client bug here. It's posting as Chunked but not including any data, or even the chunked terminator. I do wonder if there an exception happening in the client, such as when serializing the content as json, and that causes it to abort sending.

Transferring to runtime.

ghost commented 9 months ago

Tagging subscribers to this area: @dotnet/ncl See info in area-owners.md if you want to be subscribed.

Issue Details
### Is there an existing issue for this? - [X] I have searched the existing issues ### Describe the bug When running an HTTP POST or HTTP PUT request using the `HttpClient` against an ASP.NET Core Web API, it fails with the following exception: ```csharp System.Net.Http.HttpRequestException: An error occurred while sending the request. System.Net.Http.HttpRequestException An error occurred while sending the request. at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) System.IO.IOException The response ended prematurely. at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) ``` This only happens under the following circumstances: - Extension method `PutAsJsonAsync` is used - Extension method `PostAsJsonAsync` is used - `PostAsync` with `HttpContent` of `null` is used - `PostAsync` with `HttpContent` of `new StringContent(string.Empty)` is used These requests only fail when using the `HttpClient` in C#, but they succeed when running them via... - PowerShell - curl - Swagger ### Expected Behavior The HTTP PUT and POST requests do not fail. ### Steps To Reproduce 1. Clone this repository: https://github.com/mu88/Repro_HttpClient_POST_fails 2. Open the `*.sln` 3. Start the `WebApi` project 4. Run the tests In my case, the test result looks like this: ![image](https://github.com/dotnet/aspnetcore/assets/4560672/11a673b8-e461-4f81-912f-35281b04b521) When checking the `WebApi` logs, I see that the backend seems to handle the requests properly - at least I always see a `2xx` status code: ``` info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: POST Scheme: http PathBase: Path: /api/processor/process Host: localhost:5254 Content-Type: application/json; charset=utf-8 Content-Length: 50 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 204 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: PUT Scheme: http PathBase: Path: /api/processor/process Host: localhost:5254 Content-Type: application/json; charset=utf-8 Content-Length: 50 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 204 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: GET Scheme: http PathBase: Path: /api/processor/hello Host: localhost:5254 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 200 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: DELETE Scheme: http PathBase: Path: /api/processor/goodbye Host: localhost:5254 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 200 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: POST Scheme: http PathBase: Path: /internal-api/dataset/complete Host: localhost:5254 Content-Length: 0 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 204 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: POST Scheme: http PathBase: Path: /internal-api/dataset/complete Host: localhost:5254 Content-Length: 0 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 204 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: POST Scheme: http PathBase: Path: /internal-api/dataset/complete Host: localhost:5254 Content-Length: 0 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 204 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: POST Scheme: http PathBase: Path: /internal-api/dataset/complete Host: localhost:5254 Content-Length: 0 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 204 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: POST Scheme: http PathBase: Path: /internal-api/dataset/complete Host: localhost:5254 Content-Type: text/plain; charset=utf-8 Content-Length: 0 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 204 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: PUT Scheme: http PathBase: Path: /api/processor/process Host: localhost:5254 Content-Type: application/json; charset=utf-8 Transfer-Encoding: chunked info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Protocol: HTTP/1.1 Method: POST Scheme: http PathBase: Path: /api/processor/process Host: localhost:5254 Content-Type: application/json; charset=utf-8 Transfer-Encoding: chunked info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 200 info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[2] Response: StatusCode: 200 ``` The tests are only used for easier usage. Instead, the CLI project `Client` can be used as well and triggers the same exceptions. ### Exceptions (if any) ```csharp System.Net.Http.HttpRequestException: An error occurred while sending the request. System.Net.Http.HttpRequestException An error occurred while sending the request. at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) at Client.Helper.CompleteViaPostWithEmptyAsync(HttpClient httpClient) in C:\work\GitHub\Repro_HttpClient_POST_fails\Client\Helper.cs:line 49 System.IO.IOException The response ended prematurely. at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) ``` ### .NET Version 8.0.101 ### Anything else? # Additional information - ASP.NET Core 8 - Happens in both Visual Studio and JetBrains Rider - Windows 10 22H2 (OS build 19045.3930) - Output of `dotnet --info`: ``` .NET SDK: Version: 8.0.101 Commit: 6eceda187b Workload version: 8.0.100-manifests.f64b8c85 Runtime Environment: OS Name: Windows OS Version: 10.0.19045 OS Platform: Windows RID: win-x64 Base Path: C:\Program Files\dotnet\sdk\8.0.101\ .NET workloads installed: Workload version: 8.0.100-manifests.f64b8c85 [maui-maccatalyst] Installation Source: SDK 8.0.100 Manifest Version: 8.0.3/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.3\WorkloadManifest.json Install Type: Msi [maui-tizen] Installation Source: SDK 8.0.100 Manifest Version: 8.0.3/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.3\WorkloadManifest.json Install Type: Msi [maui-windows] Installation Source: VS 17.8.34408.163 Manifest Version: 8.0.3/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.3\WorkloadManifest.json Install Type: Msi [maccatalyst] Installation Source: VS 17.8.34408.163 Manifest Version: 17.0.8490/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maccatalyst\17.0.8490\WorkloadManifest.json Install Type: Msi [ios] Installation Source: VS 17.8.34408.163 Manifest Version: 17.0.8490/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.ios\17.0.8490\WorkloadManifest.json Install Type: Msi [android] Installation Source: VS 17.8.34408.163 Manifest Version: 34.0.52/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.android\34.0.52\WorkloadManifest.json Install Type: Msi Host: Version: 8.0.1 Architecture: x64 Commit: bf5e279d92 .NET SDKs installed: 2.1.700 [C:\Program Files\dotnet\sdk] 2.2.300 [C:\Program Files\dotnet\sdk] 8.0.101 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Other architectures found: x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation] Environment variables: Not set global.json file: Not found ``` - It does not matter whether .NET 7 or 8 is used (can be controlled via `Directory.Build.props`) - the exception stays the same. - I asked several colleagues to reproduce the issue with my repro case on their machines, but without luck: at the moment, I'm the only one with this problem. - Maybe related to dotnet/aspnetcore#23949 # Broader context Of course, this is a rather simplified example. In our team, we're maintaining a dozen of different apps following the same pattern which is similar to the shown example. Since we set great store by testing, we have a lot of system integration tests where we test our ASP.NET Core Web API (which is running in Docker) via `HttpClient`. Since I got a new laptop, I installed all the necessary pieces (Git, .NET SDK, Docker Desktop, etc.) and cloned several of our apps. I can run all unit and integration tests, but some of the system integration tests fail. It took me a long time to remove the complexity step by step until I noticed that only those tests fail which make use HTTP POST or PUT using the `HttpClient`. So I further removed different layers (Docker, xUnit) and reduced it down to a dumb CLI app using the `HttpClient` to access an ASP.NET Core Web API - the result is the repro repo https://github.com/mu88/Repro_HttpClient_POST_fails. ❗ So at the moment, I'm not able to run any of our system integration tests that make use of HTTP POST or PUT. Therefore, this bug has a certain impact on my inner dev loop and I'd appreciate it if you could have a look. I'm fully aware that you (as my colleagues) probably won't be able to reproduce the problem. However, I hope that you can give me some guidance on what to analyze. Thanks in advance!
Author: mu88
Assignees: -
Labels: `area-System.Net.Http`
Milestone: -
MihaZupan commented 9 months ago

I asked several colleagues to reproduce the issue with my repro case on their machines, but without luck: at the moment, I'm the only one with this problem.

This is suspicious and points at the issue being related to your environment (e.g. AV/software on the machine messing with the traffic).

For reference, I can't repro the issue either.


Can you collect a wireshark trace of the test, while also enabling debug logging in HttpClient? Modified sample with logging: https://gist.github.com/MihaZupan/331dddb261f8086b0dfc522901e221f6

ghost commented 9 months ago

This issue has been marked needs-author-action and may be missing some important information.

mu88 commented 9 months ago

Can you collect a wireshark trace of the test, while also enabling debug logging in HttpClient?

As far as I understand, I need WinPcap for Wireshark to capture traffic from localhost to localhost. I spent several hours now, but unfortunately, I cannot make WinPcap work - Wireshark never shows the loopback interface 😑 maybe it is related to a company setting of my laptop, I've no idea.

Anyhow, please see the following debug log of the HttpClient.

`PostAsJsonAsync` with client debug logging ```log 20:785 Private.InternalDiagnostics.System.Net.Http/Info: thisOrContextObject=HttpClientHandler#62474978 memberName=.ctor message= 20:790 Private.InternalDiagnostics.System.Net.Http/Info: thisOrContextObject=SocketsHttpHandler#2086040 memberName=.ctor message= 20:792 Private.InternalDiagnostics.System.Net.Http/Associate: thisOrContextObject=HttpClient#18063220 memberName=.ctor first=HttpClient#18063220 second=HttpClientHandler#62474978 20:793 Private.InternalDiagnostics.System.Net.Http/UriBaseAddress: uriBaseAddress=http://localhost:5254/ objName=HttpClient#18063220 20:794 Private.InternalDiagnostics.System.Net.Http/Info: thisOrContextObject=JsonContent#43546682 memberName=.ctor message= 20:796 Private.InternalDiagnostics.System.Net.Http/Associate: thisOrContextObject=HttpRequestMessage#64929777 memberName=Content first=HttpRequestMessage#64929777 second=JsonContent#43546682 20:797 System.Net.Http/RequestStart: scheme=http host=localhost port=5254 pathAndQuery=/api/processor/process versionMajor=1 versionMinor=1 versionPolicy=0 20:809 Private.InternalDiagnostics.System.Net.Http/Info: thisOrContextObject=HttpConnectionHandler#42253292 memberName=.ctor message= 20:810 Private.InternalDiagnostics.System.Net.Http/Info: thisOrContextObject=DiagnosticsHandler#64591461 memberName=.ctor message= 20:811 Private.InternalDiagnostics.System.Net.Http/Info: thisOrContextObject=RedirectHandler#17556181 memberName=.ctor message= 20:815 Private.InternalDiagnostics.System.Net.Quic/Info: thisOrContextObject=(null) memberName=.cctor message=Current Windows version (Microsoft Windows NT 10.0.19045.0) is not supported by QUIC. Minimal supported version is 10.0.20145.1000 20:816 Private.InternalDiagnostics.System.Net.Http/HandlerMessage: poolId=6532797 workerId=0 requestId=0 memberName=.ctor message=HttpConnectionPool Proxy http://127.0.0.1:3128/ 20:818 Private.InternalDiagnostics.System.Net.Http/HandlerMessage: poolId=6532797 workerId=0 requestId=0 memberName=CheckForHttp11ConnectionInjection message=Available HTTP/1.1 connections: 0, Requests in the queue: 1, Requests without a connection attempt: 1, Pending HTTP/1.1 connections: 0, Total associated HTTP/1.1 connections: 0, Max HTTP/1.1 connection limit: 2147483647, Will inject connection: True. 20:818 Private.InternalDiagnostics.System.Net.Http/HandlerMessage: poolId=6532797 workerId=0 requestId=0 memberName=TryGetPooledHttp11Connection message=No available HTTP/1.1 connections; request queued. 20:819 Private.InternalDiagnostics.System.Net.Http/HandlerMessage: poolId=6532797 workerId=0 requestId=0 memberName=AddHttp11ConnectionAsync message=Creating new HTTP/1.1 connection for pool. 20:821 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#37916227 memberName=.ctor message=InterNetworkV6 20:821 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=(null) memberName=CreateSocket message=SafeSocketHandle:63403007(0x6F0) 20:822 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#37916227 memberName=SetSocketOption message=optionLevel:IPv6 optionName:IPv6Only optionValue:0 20:822 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#37916227 memberName=SetSocketOption message=SetSockOpt returns errorCode:Success 20:822 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#37916227 memberName=SetSocketOption message=optionLevel:Tcp optionName:NoDelay optionValue:1 20:823 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#37916227 memberName=SetSocketOption message=SetSockOpt returns errorCode:Success 20:824 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=AwaitableSocketAsyncEventArgs#4916187 memberName=InitializeInternals message=new PreAllocatedOverlapped PreAllocatedOverlapped#59231349 20:824 Private.InternalDiagnostics.System.Net.Sockets/ConnectedAsyncDns: socketHash=37916227 20:825 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=MultiConnectSocketAsyncEventArgs#52253787 memberName=InitializeInternals message=new PreAllocatedOverlapped PreAllocatedOverlapped#17987329 20:826 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#37916227 memberName=GetSocketOption message=GetSockOpt returns errorCode:Success 20:827 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#37916227 memberName=GetSocketOption message=GetSockOpt returns errorCode:Success 20:827 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#37916227 memberName=GetSocketOption message=GetSockOpt returns errorCode:Success 20:828 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#37916227 memberName=WildcardBindForConnectIfNecessary message=[::]:0 20:828 System.Net.Sockets/ConnectStart: address=InterNetworkV6:28:{12,56,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,127,0,0,1,0,0,0,0} 20:828 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=SafeSocketHandle#63403007 memberName=GetOrAllocateThreadPoolBoundHandle message=calling ThreadPool.BindHandle() 20:831 Private.InternalDiagnostics.System.Net.Sockets/Connected: localEp=IPEndPoint#725322072 remoteEp=(null) socketHash=37916227 20:831 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#37916227 memberName=SetToConnected message=now connected 20:831 System.Net.Sockets/ConnectStop: 20:832 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#37916227 memberName=Connected message=_isConnected:True 20:833 System.Net.Http/ConnectionEstablished: versionMajor=1 versionMinor=1 20:834 Private.InternalDiagnostics.System.Net.Http/HandlerMessage: poolId=6532797 workerId=31364015 requestId=0 memberName=TraceConnection message=HttpConnection(HttpConnectionPool Proxy http://127.0.0.1:3128/) 20:834 Private.InternalDiagnostics.System.Net.Http/HandlerMessage: poolId=6532797 workerId=31364015 requestId=0 memberName=ReturnHttp11Connection message=isNewConnection=True 20:835 Private.InternalDiagnostics.System.Net.Http/HandlerMessage: poolId=6532797 workerId=31364015 requestId=0 memberName=ReturnHttp11Connection message=Dequeued waiting HTTP/1.1 request. 20:835 System.Net.Http/RequestLeftQueue: timeOnQueueMilliseconds=16.1848 versionMajor=1 versionMinor=1 20:836 Private.InternalDiagnostics.System.Net.Http/HandlerMessage: poolId=6532797 workerId=31364015 requestId=64929777 memberName=SendAsyncCore message=Sending request: Method: POST, RequestUri: 'http://localhost:5254/api/processor/process', Version: 1.1, Content: System.Net.Http.Json.JsonContent, Headers: { Transfer-Encoding: chunked Content-Type: application/json; charset=utf-8 } 20:837 System.Net.Http/RequestHeadersStart: 20:838 System.Net.Http/RequestHeadersStop: 20:841 Private.InternalDiagnostics.System.Net.Http/HandlerMessage: poolId=6532797 workerId=31364015 requestId=64929777 memberName=SendAsyncCore message=Request content is not null, start processing it. hasExpectContinueHeader = False 20:842 System.Net.Http/RequestContentStart: 20:857 Private.InternalDiagnostics.System.Net.Http/HandlerMessage: poolId=6532797 workerId=31364015 requestId=64929777 memberName=WriteToStreamAsync message=Writing 216 bytes. 20:858 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=AwaitableSocketAsyncEventArgs#35903099 memberName=InitializeInternals message=new PreAllocatedOverlapped PreAllocatedOverlapped#23816093 20:858 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=AwaitableSocketAsyncEventArgs#35903099 memberName=LogBuffer buffer=504F535420687474703A2F2F6C6F63616C686F73743A353235342F6170692F70726F636573736F722F70726F6365737320485454502F312E310D0A486F73743A206C6F63616C686F73743A353235340D0A5472616E736665722D456E636F64696E673A206368756E6B65640D0A436F6E74656E742D547970653A206170706C69636174696F6E2F6A736F6E3B20636861727365743D7574662D380D0A0D0A32460D0A7B226A6F624964656E746966696572223A226D753838222C22636F6E6669726D4A6F625374617274223A747275657D0D0A300D0A0D0A 20:858 System.Net.Http/RequestContentStop: contentLength=47 20:859 Private.InternalDiagnostics.System.Net.Http/HandlerMessage: poolId=6532797 workerId=31364015 requestId=64929777 memberName=SendRequestContentAsync message=Finished sending request content. 20:888 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 20:889 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 20:889 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=810000000A00000000000000 20:890 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:129 20:890 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:129 20:891 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=7D000000B09E784FE798D3AD000049420F0000000000619C308163536994010000000002000000011000000016BC4AB12CE94C4C9EB6EBFDF2EAB70601B6C035A3A12BDC480000FFFFFFFF00FFFFFFFFFFFFFFFF01100000007FD133FF92021B4195976B2FD7C75CC901A03C35A3A12BDC480000FFFFFFFF00FFFFFFFFFFFFFFFF 20:892 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:13051 20:893 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=1A0000000A000000000000001600000049420F00000000000000000000000000000000000000 20:893 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Connected message=_isConnected:True 20:895 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:13013 21:133 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF0000000000000000 21:135 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:13001 21:150 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 21:151 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 21:152 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF0000000000000000 21:638 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF0100000000000000 21:639 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12989 21:654 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 21:655 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 21:655 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF0100000001000000 22:140 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF0200000001000000 22:141 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12977 22:170 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 22:171 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 22:172 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF0200000002000000 22:642 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF0300000002000000 22:643 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12965 22:687 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 22:688 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 22:689 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF0300000003000000 23:157 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF0400000003000000 23:158 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12953 23:203 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 23:205 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 23:206 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF0400000004000000 23:658 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF0500000004000000 23:659 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12941 23:721 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 23:722 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 23:722 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF0500000005000000 24:161 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF0600000005000000 24:163 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12929 24:225 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 24:226 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 24:227 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF0600000006000000 24:666 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF0700000006000000 24:667 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12917 24:728 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 24:729 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 24:730 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF0700000007000000 25:167 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF0800000007000000 25:168 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12905 25:246 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 25:247 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 25:247 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF0800000008000000 25:682 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF0900000008000000 25:683 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12893 25:758 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 25:760 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 25:762 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF0900000009000000 26:182 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF0A00000009000000 26:183 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12881 26:277 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 26:278 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 26:279 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF0A0000000A000000 26:686 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF0B0000000A000000 26:686 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12869 26:795 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 26:795 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 26:796 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF0B0000000B000000 27:200 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF0C0000000B000000 27:201 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12857 27:310 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 27:311 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 27:312 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF0C0000000C000000 27:715 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF0D0000000C000000 27:716 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12845 27:824 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 27:825 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 27:825 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF0D0000000D000000 28:216 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF0E0000000D000000 28:218 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12833 28:326 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 28:327 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 28:328 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF0E0000000E000000 28:716 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF0F0000000E000000 28:717 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12821 28:840 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 28:841 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 28:842 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF0F0000000F000000 29:231 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF100000000F000000 29:232 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12809 29:347 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 29:348 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 29:348 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF1000000010000000 29:747 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF1100000010000000 29:747 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12797 29:856 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 29:857 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 29:858 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF1100000011000000 30:247 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF1200000011000000 30:248 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12785 30:369 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 30:370 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 30:370 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF1200000012000000 30:758 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF1300000012000000 30:759 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12773 30:883 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 30:884 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 30:884 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF1300000013000000 31:260 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF1400000013000000 31:261 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12761 31:386 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 31:387 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 31:388 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF1400000014000000 31:773 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF1500000014000000 31:774 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12749 31:898 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 31:899 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 31:901 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF1500000015000000 32:287 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF1600000015000000 32:288 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12737 32:412 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 32:413 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 32:414 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF1600000016000000 32:802 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF1700000016000000 32:803 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12725 32:926 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 32:927 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 32:928 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF1700000017000000 33:311 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF1800000017000000 33:313 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12713 33:429 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 33:429 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 33:430 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF1800000018000000 33:819 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF1900000018000000 33:820 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12701 33:943 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 33:944 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 33:945 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF1900000019000000 34:322 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF1A00000019000000 34:323 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12689 34:448 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 34:449 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 34:449 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF1A0000001A000000 34:824 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF1B0000001A000000 34:825 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12677 34:963 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 34:964 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 34:965 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF1B0000001B000000 35:328 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF1C0000001B000000 35:331 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12665 35:476 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 35:478 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 35:479 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF1C0000001C000000 35:835 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF1D0000001C000000 35:837 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12653 35:989 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 35:991 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 35:992 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF1D0000001D000000 36:335 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF1E0000001D000000 36:336 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12641 36:506 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 36:508 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 36:509 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF1E0000001E000000 36:844 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF1F0000001E000000 36:845 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12629 37:017 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 37:019 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 37:021 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF1F0000001F000000 37:355 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF200000001F000000 37:356 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12617 37:527 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 37:529 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 37:530 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF2000000020000000 37:868 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF2100000020000000 37:869 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12605 38:045 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 38:047 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 38:047 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF2100000021000000 38:372 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF2200000021000000 38:374 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12593 38:561 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 38:563 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 38:564 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF2200000022000000 38:875 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF2300000022000000 38:877 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12581 39:078 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 39:079 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 39:080 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF2300000023000000 39:389 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF2400000023000000 39:391 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12569 39:590 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 39:591 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 39:592 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF2400000024000000 39:902 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF2500000024000000 39:904 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12557 40:105 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 40:106 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 40:107 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF2500000025000000 40:403 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF2600000025000000 40:404 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12545 40:620 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12 40:621 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Send message=Send returns:12 40:622 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Send buffer=FEFFFFFF2600000026000000 40:890 Private.InternalDiagnostics.System.Net.Http/HandlerMessage: poolId=6532797 workerId=31364015 requestId=64929777 memberName=InitialFillAsync message=Received 0 bytes. 40:896 Private.InternalDiagnostics.System.Net.Http/HandlerMessage: poolId=6532797 workerId=31364015 requestId=64929777 memberName=SendAsyncCore message=Error sending request: System.IO.IOException: The response ended prematurely. at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) 40:897 Private.InternalDiagnostics.System.Net.Http/HandlerMessage: poolId=6532797 workerId=31364015 requestId=64929777 memberName=Dispose message=Connection closing. 40:898 System.Net.Http/ConnectionClosed: versionMajor=1 versionMinor=1 40:899 Private.InternalDiagnostics.System.Net.Http/HandlerMessage: poolId=6532797 workerId=0 requestId=0 memberName=CheckForHttp11ConnectionInjection message=Available HTTP/1.1 connections: 0, Requests in the queue: 0, Requests without a connection attempt: 0, Pending HTTP/1.1 connections: 0, Total associated HTTP/1.1 connections: 0, Max HTTP/1.1 connection limit: 2147483647, Will inject connection: False. 40:899 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#37916227 memberName=Close message=timeout = -1 40:900 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#37916227 memberName=Dispose message=timeout = -1 40:900 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#37916227 memberName=Dispose message=disposing:True Disposed:False 40:901 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#37916227 memberName=Dispose message=Calling _handle.CloseAsIs() 40:901 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=SafeSocketHandle#63403007 memberName=CloseAsIs message=abortive=False, shouldClose =True 40:902 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=SafeSocketHandle#63403007 memberName=ReleaseHandle message=shouldClose=False 40:902 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=SafeSocketHandle#63403007 memberName=CloseHandle message=handle:0x6F0 40:902 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=SafeSocketHandle#63403007 memberName=DoCloseHandle message=handle:0x6F0, Following 'blockable' branch 40:903 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=SafeSocketHandle#63403007 memberName=DoCloseHandle message=handle:0x6F0, closesocket()#1:Success 40:903 Private.InternalDiagnostics.System.Net.Sockets/DumpBuffer: thisOrContextObject=Socket#12036987 memberName=Receive buffer=FEFFFFFF2700000026000000 40:904 Private.InternalDiagnostics.System.Net.Sockets/Info: thisOrContextObject=Socket#12036987 memberName=Receive message=SRC:127.0.0.1:64420 DST:127.0.0.1:64419 size:12533 40:904 System.Net.Http/RequestFailed: exceptionMessage=An error occurred while sending the request. 40:906 Private.InternalDiagnostics.System.Net.Http/ErrorMessage: thisOrContextObject=HttpClient#18063220 memberName=HandleFailure message=System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.IO.IOException: The response ended prematurely. at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) 40:906 System.Net.Http/RequestStop: statusCode=-1 ```
ManickaP commented 9 months ago

The logged buffer looks correct:

0D0A
0D0A
3246 -- chunk size 2F (47)
0D0A
7B226A6F624964656E746966696572223A226D753838222C22636F6E6669726D4A6F625374617274223A747275657D -- chunk data {"jobIdentifier":"mu88","confirmJobStart":true}
0D0A
30 -- final chunk size 0
0D0A
0D0A

Can you reproduce this on another machine? What about your coworkers, do they have the same problem? You can minimize the repro to simple console app and try it out on different machines/vms. But this does not look like HttpClient issue. From the logs, the data went out in correct form.

ghost commented 9 months ago

This issue has been marked needs-author-action and may be missing some important information.

mu88 commented 9 months ago

Unfortunately, I'm the only one facing this issue. I already asked several colleagues to run my little repro suite and it succeeded for all of them.

ManickaP commented 9 months ago

So this is surely environmental and specific to your machine and your set up. I'd recommend trying to turn off one by one any and every program that might interfere with network traffic, e.g. antivirus, VPN, proxy etc., and see if anything helps. Otherwise, there isn't much we could help you with.

Tratcher commented 9 months ago

You can capture what the server received using server connection logging: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel/connection-middleware?view=aspnetcore-8.0#connection-logging

mu88 commented 9 months ago

I was finally able to resolve the issue: I'm running an instance of px proxy on my machine and stopping it broke the whole test suite, which confused me. So I started removing the env vars http_proxy and https_proxy and out of a sudden, the tests were all green ✅ So I set the no_proxy env var to localhost, 127.0.0.1, started px proxy and the tests were still all green.

Long story short: px proxy resp. not configuring no_proxy was the problem.

Thank you very much for your help! I really appreciate it that you gave me your precious time 🙏🏻