{"action":"opened","issue":{"url":"https://api.github.com/repos/aspnet/Hosting/issues/1367","repository_url":"https://api.github.com/repos/aspnet/Hosting","labels_url":"https://api.github.com/repos/aspnet/Hosting/issues/1367/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/Hosting/issues/1367/comments","events_url":"https://api.github.com/repos/aspnet/Hosting/issues/1367/events","html_url":"https://github.com/aspnet/Hosting/issues/1367","id":309144373,"number":1367,"title":"WebHost.RunAsync doesn't stop when Kestrel cannot listen on a particular port.","user":{"login":"ravarnamsft","id":36653801,"avatar_url":"https://avatars3.githubusercontent.com/u/36653801?v=4","gravatar_id":"","url":"https://api.github.com/users/ravarnamsft","html_url":"https://github.com/ravarnamsft","followers_url":"https://api.github.com/users/ravarnamsft/followers","following_url":"https://api.github.com/users/ravarnamsft/following{/other_user}","gists_url":"https://api.github.com/users/ravarnamsft/gists{/gist_id}","starred_url":"https://api.github.com/users/ravarnamsft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ravarnamsft/subscriptions","organizations_url":"https://api.github.com/users/ravarnamsft/orgs","repos_url":"https://api.github.com/users/ravarnamsft/repos","events_url":"https://api.github.com/users/ravarnamsft/events{/privacy}","received_events_url":"https://api.github.com/users/ravarnamsft/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-27T21:41:58Z","updated_at":"2018-03-27T21:41:58Z","closed_at":null,"author_association":"NONE","body":"I am using await webHost.RunAsync() in our .Net Core project (Nuget- Asp.NetCoreAll 2.0.3). On Ubuntu 16.04 (Azure VM), I am observing that whenever there is a port conflict, kestrel seems to throw an exception but the awaiting on webHost.RunAsync() doesn't throw or return a completed Task. This makes it harder for us to detect our application failure and take recovery action. Is this a known issue / fixed in later releases?\r\n\r\nHere is the exception from kestrel:\r\n\r\n2018-03-27T21:19:57.3909067+00:00  [FTL] Unable to start Kestrel. (fc6a528d)\r\nSystem.IO.IOException: Failed to bind to address https://0.0.0.0:5002: address                                                                                                                                                              already in use. ---> Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.                                                                                                                                                             Internal.AddressInUseException: Error -98 EADDRINUSE address already in use --->                                                                                                                                                              Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.UvExcep                                                                                                                                                             tion: Error -98 EADDRINUSE address already in use\r\n   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.Li                                                                                                                                                             buvFunctions.ThrowError(Int32 statusCode)\r\n   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.Uv                                                                                                                                                             TcpHandle.GetSockIPEndPoint()\r\n   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Listener.List                                                                                                                                                             enTcp(Boolean useFileHandle)\r\n   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Listener.<>c.                                                                                                                                                             <StartAsync>b__8_0(Listener listener)\r\n   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.LibuvThread.D                                                                                                                                                             oPostWork()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot                                                                                                                                                             ification(Task task)\r\n   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.ListenerPrima                                                                                                                                                             ry.<StartAsync>d__15.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot                                                                                                                                                             ification(Task task)\r\n   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.LibuvTransport.<BindAs                                                                                                                                                             ync>d__20.MoveNext()\r\n   --- End of inner exception stack trace ---\r\n   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.LibuvTransport.<BindAs                                                                                                                                                             ync>d__20.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot                                                                                                                                                             ification(Task task)\r\n   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<>c__DisplayClass21                                                                                                                                                             _0`1.<<StartAsync>g__OnBind|0>d.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot                                                                                                                                                             ification(Task task)\r\n   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.<BindEndpo                                                                                                                                                             intAsync>d__5.MoveNext()\r\n   --- End of inner exception stack trace ---\r\n   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.<BindEndpo                                                                                                                                                             intAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot                                                                                                                                                             ification(Task task)\r\n   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.EndpointsS                                                                                                                                                             trategy.<BindAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot                                                                                                                                                             ification(Task task)\r\n   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.<BindAsync                                                                                                                                                             >d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot                                                                                                                                                             ification(Task task)\r\n   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<StartAsync>d__21`1                                                                                                                                                             .MoveNext()\r\n\r\n\r\nInstead, if I just do the following, it seems to just work:\r\nawait host.StartAsync();\r\nawait host.WaitForShutdownAsync();\r\n\r\nMost of the online documentation and the default VS project template uses Run/RunAsync, so I am not sure if I should directly use StartAsync and WaitForShutdownAsync. Looking at the RunAsync it does mostly the same thing with some additional ManualResetEvents."}}
{"actor":{"display_login":"ravarnamsft"}}