Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Not responding - UvException: Error -107 ENOTCONN socket is not connected #2583

Closed
khancyai opened this issue May 17, 2018 · 6 comments
Closed

Comments

@khancyai
Copy link

khancyai commented May 17, 2018

Hi, Kestrel http server behind of nginx (centOS), sometimes randomly hanging not responding.

This time a got this error message ;

fail: Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv[0]
May 17 05:36:39 myserver[11532]: Listener.OnConnection
May 17 05:36:39 myserver[11532]: Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.UvException: Error -107 ENOTCONN socket is not connected
May 17 05:36:39 myserver[11532]: at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.LibuvFunctions.ThrowError(Int32 statusCode)
May 17 05:36:39 myserver[11532]: at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.LibuvFunctions.tcp_getpeername(UvTcpHandle handle, SockAddr& addr, Int32& namelen)
May 17 05:36:39 myserver[11532]: at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.UvTcpHandle.GetPeerIPEndPoint()
May 17 05:36:39 myserver[11532]: at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.LibuvConnection..ctor(ListenerContext context, UvStreamHandle socket)
May 17 05:36:39 myserver[11532]: at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Listener.DispatchConnection(UvStreamHandle socket)
May 17 05:36:39 myserver[11532]: at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Listener.OnConnection(UvStreamHandle listenSocket, Int32 status)
May 17 05:36:39 myserver[11532]: fail: Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv[0]
May 17 05:36:39 myserver[11532]: Listener.OnConnection
May 17 05:36:39 myserver[11532]: Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.UvException: Error -107 ENOTCONN socket is not connected
May 17 05:36:39 myserver[11532]: at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.LibuvFunctions.ThrowError(Int32 statusCode)
May 17 05:36:39 myserver[11532]: at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.LibuvFunctions.tcp_getpeername(UvTcpHandle handle, SockAddr& addr, Int32& namelen)
May 17 05:36:39 myserver[11532]: at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.UvTcpHandle.GetPeerIPEndPoint()
May 17 05:36:39 myserver[11532]: at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.LibuvConnection..ctor(ListenerContext context, UvStreamHandle socket)
May 17 05:36:39 myserver[11532]: at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Listener.DispatchConnection(UvStreamHandle socket)
May 17 05:36:39 myserver[11532]: at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Listener.OnConnection(UvStreamHandle listenSocket, Int32 status)
May 17 05:36:46 myserver[11532]: info: Microsoft.AspNetCore.Server.Kestrel[17]
May 17 05:36:46 myserver[11532]: Connection id "0HLDRI6731JP6" bad request data: "Invalid request line: '\x0D\x0A'"
May 17 05:36:46 myserver[11532]: Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Invalid request line: '\x0D\x0A'
May 17 05:36:46 myserver[11532]: at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpParser`1.RejectRequestLine(Byte* requestLine, Int32 length)
May 17 05:36:46 myserver[11532]: at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpParser`1.GetUnknownMethod(Byte* data, Int32 length, Int32& methodLength)
May 17 05:36:46 myserver[11532]: at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpParser`1.ParseRequestLine(TRequestHandler handler, Byte* data, Int32 length)
May 17 05:36:46 myserver[11532]: at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpParser`1.ParseRequestLine(TRequestHandler handler, ReadableBuffer buffer, ReadCursor& consumed, ReadCursor& examined)
May 17 05:36:46 myserver[11532]: at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Frame.TakeStartLine(ReadableBuffer buffer, ReadCursor& consumed, ReadCursor& examined)
May 17 05:36:46 myserver[11532]: at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Frame.ParseRequest(ReadableBuffer buffer, ReadCursor& consumed, ReadCursor& examined)
May 17 05:36:46 myserver[11532]: at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Frame`1.<ProcessRequestsAsync>d__2.MoveNext()
May 17 05:36:46 myserver[11532]: info: Microsoft.AspNetCore.Server.Kestrel[17]
@halter73
Copy link
Member

The ENOTCONN is a badly reported connection reset that happens almost immediately after the connection is established. We're cleaning up the logging for this with #2547.

The following log is more interesting:

Microsoft.AspNetCore.Server.Kestrel[17] May 17 05:36:46 myserver[11532]: Connection id "0HLDRI6731JP6" bad request data: "Invalid request line: '\x0D\x0A'" May 17 05:36:46 myserver[11532]: Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Invalid request line: '\x0D\x0A'

This is saying that a carriage return line feed (\r\n) was received at the start of the request instead of the expected HTTP method (e.g. GET). This is invalid HTTP so the request is rejected. This can be caused by any random misbehaving client which is why it's logged with a relatively low "info" severity, but if the invalid request is coming from your client, that could explain the observed hang.

@halter73
Copy link
Member

#2547 is in dev which should fix the error reporting for the ENOTCONN. Are you still seeing BadHttpRequestException?

@halter73 halter73 reopened this May 22, 2018
@halter73
Copy link
Member

Didn't mean to close.

@shirhatti
Copy link

Hi. We're closing this issue as no response or updates have been provided in a timely manner and we have been unable to reproduce it. If you have more details and are encountering this issue please add a new reply and re-open the issue.

@khancyai
Copy link
Author

Hi, thank you for efforts, didn't understand how do i fix the problem?

@halter73
Copy link
Member

@khancyai Upgrading to ASP.NET Core 2.1 should remove the ENOTCONN logs you're seeing. As for the BadHttpRequestException, I'll quote my previous response:

This is saying that a carriage return line feed (\r\n) was received at the start of the request instead of the expected HTTP method (e.g. GET). This is invalid HTTP so the request is rejected. This can be caused by any random misbehaving client which is why it's logged with a relatively low "info" severity, but if the invalid request is coming from your client, that could explain the observed hang.

If you're still seeing BadHttpRequestExceptions and you think that the client is in fact sending valid requests, we'll need some more details about what client you're using (browser, c# HttpClient, etc...) and how you're using it. As far as I'm aware no one else has reported this kind of BadHttpRequestException before so I'm guessing there must be something fairly unusual going on.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants