dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.45k stars 10.03k forks source link

Error -4077 ECONNRESET connection reset by peer #1741

Closed anobaka closed 8 years ago

anobaka commented 8 years ago

environment:

exception:

info: Microsoft.AspNetCore.Server.Kestrel[14]
      Connection id "0HKUNP9IK98PK" communication error
      Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvException: Error -4077 ECONNRESET connection reset by peer

reproduction: what I've done and what happend:

  1. publish to production servers and configure the load balance.
  2. configure domain forward to the ip of load balance.
  3. use some special browser to access the website.
  4. iis's 502 error page shows.

here's fail request log in iis:

MODULE_SET_RESPONSE_ERROR_STATUS

Warning
 ModuleName="AspNetCoreModule", Notification="EXECUTE_REQUEST_HANDLER", HttpStatus="502", HttpReason="Bad Gateway", HttpSubStatus="3", ErrorCode="2147954552", ConfigExceptionInfo="" 

It's very strange thing, the exception throwed only when all above conditions are met, and if one of them missed(eg. using local host settings instead of configuring the real domain forward to the ip of the lb, or using other browsers), the website can be accessed successfully.

Please help, some of our users are blocked by this. Thanks.

guardrex commented 8 years ago

@anobaka Move this over to https://github.com/aspnet/IISIntegration/issues to get more :eyes: on it and close it here. Wait. @Tratcher is watching here, and he might say this is a Kestrel thing.

Tratcher commented 8 years ago

Kestrel says IIS closed the connection (though it's unclear when in the request this happened). IIS says Kestrel failed to respond in a timely fashion, which may be why it closed the connection. How long was the request running before this happened? What was the request trying to do?

anobaka commented 8 years ago

@Tratcher The response time is less than 1 second, even than 100 ms, it just responses immediately. The request is just to access the homepage of website.

You can try this:

  1. install QQBrowser in IOS 9.3.x.(Chinese version, called "QQ浏览器" in Chinese)
  2. access http://ahstest.aihuishou.com in QQBrowser.
  3. the 502 response shows.

My tests:

My attempts:

Any idea? Thanks.

Tratcher commented 8 years ago

Use Microsoft Message Analyzer to trace the packets coming into the server and see what the raw header values are. https://www.microsoft.com/en-us/download/details.aspx?id=44226

anobaka commented 8 years ago

Thanks, it's powerful. Here's the packets.502.tar.gz MessageNumber 28868 & 808129 are the 502 responded requests sended by some special browsers. MessageNumber 633002 is the 200 responded request sended by other browsers.

Update It maybe the x-forwarded-for header, when I add a comma into x-forwarded-for header, it returns 502, but 200 for other special characters like . ?.

Update2 I removed the x-forwarded-for(F5XFFHttpModule.dll) module in IIS I added before, it seems to work.

Tratcher commented 8 years ago

@anobaka glad you found it, is this good to close now?

anobaka commented 8 years ago

@Tratcher , of course, thanks for your help.