Kestrel: handling of FIN comming from client

See original GitHub issue

This issue has been talked about in the archived repo aspnet/KestrelHttpServer SocketTransport: FIN handling but I’m not sure what the outcome is. I’ve search for commits mentioned in issue 1774 in this repo but found nothing.

My problem is that a TCP client is making an HTTP POST request to an ASP.NET Core WebAPI. After getting back an ACK the client sends immediately FIN, ACK. Subsequently, Kestrel closes the connection so the client does not get the response. Although the corresponding MVC action finishes and returns an IActionResult. No error/warning is raised on the server-side.

Lib: Microsoft.AspNetCore.App: 2.2.6 Runtime: netcoreapp2.2 OS: Windows 10 x64 SDK: 2.2.301

You can see the actual behavior in this screenshot of the communication captured with wireshark. Port 51852 is the client initiating the connection. Port 6200 is Kestrel.

image

I tested the same a client with a mock service (SoapUI) that provides the expected behavior.

image


By the way: using HttpSys an exception is thrown if my action returns, i.e. both servers have different behavior.

 Microsoft.AspNetCore.Server.HttpSys.MessagePump[0]
      ProcessRequestAsync
System.InvalidOperationException: Headers already sent.
   at Microsoft.AspNetCore.Server.HttpSys.Response.CheckResponseStarted()
   at Microsoft.AspNetCore.Server.HttpSys.FeatureContext.ConsiderEnablingResponseCache()
   at Microsoft.AspNetCore.Server.HttpSys.FeatureContext.OnResponseStart()
   at Microsoft.AspNetCore.Server.HttpSys.MessagePump.ProcessRequestAsync(Object requestContextObj)
   at Microsoft.AspNetCore.Server.HttpSys.MessagePump.ProcessRequestAsync(Object requestContextObj)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
davidfowlcommented, Mar 29, 2021

BTW the scenario of a browser using EventSource with Kestrel server pushing is quite uncommon as it’s a good practice to add a reverse proxy in the middle. Haven’t seen any non-toy application connect a browser directly to Kestrel.

2 years later lots of people using Kestrel “on the edge” 😉

0reactions
halter73commented, Jun 1, 2021

This issue hasn’t had any external activity in over a year, and I think we’re happy with the current behavior.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to detect a connection closure in Kestrel
Sockets[7] Connection id "0HMCEE5LHGSKR" sending FIN because: "The client closed the connection." dbug: Microsoft.AspNetCore.Server.Kestrel.
Read more >
Exception "Handle is already used by another Socket. ...
Kestrel.Transport.Sockets[7] Connection id "0HMC2S69SDRQL" sending FIN because: "The Socket transport's send loop completed gracefully.".
Read more >
You're using HttpClient wrong and it is destabilizing your ...
I've been using HttpClient wrong for years and it finally came back to bite me. My site was unstable and my clients furious,...
Read more >
Kestrel web server in ASP.NET Core
Kestrel checks every second if data is arriving at the specified rate in bytes/second. If the rate drops below the minimum, the connection...
Read more >
FAQs / esg data
Below are some of the questions we often hear from clients. ... What is Kestrel ESG Impact Data? ... Does Kestrel offer customized...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found