{"action":"created","issue":{"url":"https://api.github.com/repos/NLog/NLog.Web/issues/292","repository_url":"https://api.github.com/repos/NLog/NLog.Web","labels_url":"https://api.github.com/repos/NLog/NLog.Web/issues/292/labels{/name}","comments_url":"https://api.github.com/repos/NLog/NLog.Web/issues/292/comments","events_url":"https://api.github.com/repos/NLog/NLog.Web/issues/292/events","html_url":"https://github.com/NLog/NLog.Web/issues/292","id":328929560,"node_id":"MDU6SXNzdWUzMjg5Mjk1NjA=","number":292,"title":"Get SocketConnection.StartAsync System.ObjectDisposedException when shutdown","user":{"login":"seanmars","id":4590764,"node_id":"MDQ6VXNlcjQ1OTA3NjQ=","avatar_url":"https://avatars1.githubusercontent.com/u/4590764?v=4","gravatar_id":"","url":"https://api.github.com/users/seanmars","html_url":"https://github.com/seanmars","followers_url":"https://api.github.com/users/seanmars/followers","following_url":"https://api.github.com/users/seanmars/following{/other_user}","gists_url":"https://api.github.com/users/seanmars/gists{/gist_id}","starred_url":"https://api.github.com/users/seanmars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seanmars/subscriptions","organizations_url":"https://api.github.com/users/seanmars/orgs","repos_url":"https://api.github.com/users/seanmars/repos","events_url":"https://api.github.com/users/seanmars/events{/privacy}","received_events_url":"https://api.github.com/users/seanmars/received_events","type":"User","site_admin":false},"labels":[{"id":954069037,"node_id":"MDU6TGFiZWw5NTQwNjkwMzc=","url":"https://api.github.com/repos/NLog/NLog.Web/labels/needs%20response%20from%20NLog","name":"needs response from NLog","color":"d93f0b","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-04T06:53:25Z","updated_at":"2018-06-05T02:55:33Z","closed_at":null,"author_association":"NONE","body":"**Type** (choose one):\r\n\r\n- Bug\r\n\r\n**NLog version**: \r\n\r\n```xml\r\n<PackageReference Include=\"NLog\" Version=\"4.5.6\" />\r\n<PackageReference Include=\"NLog.Web.AspNetCore\" Version=\"4.5.4\" />\r\n```\r\n\r\n**Platform**:\r\n```text\r\n.NET Core SDK (reflecting any global.json):\r\n Version:   2.1.300\r\n Commit:    adab45bf0c\r\n\r\nRuntime Environment:\r\n OS Name:     Windows\r\n OS Version:  10.0.16299\r\n OS Platform: Windows\r\n RID:         win10-x64\r\n Base Path:   C:\\Program Files\\dotnet\\sdk\\2.1.300\\\r\n\r\nHost (useful for support):\r\n  Version: 2.1.0\r\n  Commit:  caa7b7e2ba\r\n\r\n.NET Core SDKs installed:\r\n  2.1.104 [C:\\Program Files\\dotnet\\sdk]\r\n  2.1.201 [C:\\Program Files\\dotnet\\sdk]\r\n  2.1.300 [C:\\Program Files\\dotnet\\sdk]\r\n\r\n.NET Core runtimes installed:\r\n  Microsoft.AspNetCore.All 2.1.0 [C:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.All]\r\n  Microsoft.AspNetCore.App 2.1.0 [C:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.App]\r\n  Microsoft.NETCore.App 2.0.6 [C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App]\r\n  Microsoft.NETCore.App 2.0.7 [C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App]\r\n  Microsoft.NETCore.App 2.1.0 [C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App]\r\n```\r\n\r\n**Current NLog config** (xml or C#, if relevant)\r\n\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<nlog xmlns=\"http://www.nlog-project.org/schemas/NLog.xsd\"\r\n  xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n  autoReload=\"true\"\r\n  internalLogLevel=\"trace\"\r\n  internalLogFile=\"./log/internal-nlog.log\">\r\n  <targets>\r\n  </targets>\r\n  <rules>\r\n  </rules>\r\n</nlog>\r\n```\r\n\r\n**Case**\r\n\r\nWhen i use this script below to call the shotdown method, I get `SocketConnection.StartAsync System.ObjectDisposedException `. \r\nIt 100% happened when i startup the server and accessed the website and ctrl+c the service immediately, but if i don't close server immediately, i not 100% happen.\r\n\r\n```csharp\r\nvar logger = NLog.Web.NLogBuilder.ConfigureNLog(\"nlog.config\").GetCurrentClassLogger();\r\ntry\r\n{\r\n    logger.Debug(\"init main\");\r\n    BuildWebHost(args).Run(); \r\n}\r\ncatch (Exception ex)\r\n{\r\n    //NLog: catch setup errors\r\n    logger.Error(ex, \"Stopped program because of exception\");\r\n    throw;\r\n}\r\nfinally\r\n{\r\n    // Ensure to flush and stop internal timers/threads before application-exit (Avoid segmentation fault on Linux)\r\n    NLog.LogManager.Shutdown();\r\n}\r\n```\r\n\r\n**Log information**\r\n\r\n```log\r\nMicrosoft.AspNetCore.Server.Kestrel.Transport.Sockets|Unexpected exception in SocketConnection.StartAsync\r\nSystem.ObjectDisposedException: Cannot access a disposed object.\r\nObject name: 'MemoryPoolBlock'.\r\n   at System.Buffers.ThrowHelper.ThrowObjectDisposedException(ExceptionArgument argument)\r\n   at System.Buffers.MemoryPoolBlock.Dispose()\r\n   at System.IO.Pipelines.BufferSegment.ResetMemory()\r\n   at System.IO.Pipelines.Pipe.CompletePipe()\r\n   at System.IO.Pipelines.Pipe.CompleteWriter(Exception exception)\r\n   at System.IO.Pipelines.Pipe.DefaultPipeWriter.Complete(Exception exception)\r\n   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.DoReceive()\r\n   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.StartAsync(IConnectionDispatcher connectionDispatcher)\r\n```\r\n\r\n** internal-nlog.log **\r\nhttps://gist.github.com/seanmars/cc434e184d35c5b8f8fec4e942e7c6ef"},"comment":{"url":"https://api.github.com/repos/NLog/NLog.Web/issues/comments/394565096","html_url":"https://github.com/NLog/NLog.Web/issues/292#issuecomment-394565096","issue_url":"https://api.github.com/repos/NLog/NLog.Web/issues/292","id":394565096,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NDU2NTA5Ng==","user":{"login":"seanmars","id":4590764,"node_id":"MDQ6VXNlcjQ1OTA3NjQ=","avatar_url":"https://avatars1.githubusercontent.com/u/4590764?v=4","gravatar_id":"","url":"https://api.github.com/users/seanmars","html_url":"https://github.com/seanmars","followers_url":"https://api.github.com/users/seanmars/followers","following_url":"https://api.github.com/users/seanmars/following{/other_user}","gists_url":"https://api.github.com/users/seanmars/gists{/gist_id}","starred_url":"https://api.github.com/users/seanmars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seanmars/subscriptions","organizations_url":"https://api.github.com/users/seanmars/orgs","repos_url":"https://api.github.com/users/seanmars/repos","events_url":"https://api.github.com/users/seanmars/events{/privacy}","received_events_url":"https://api.github.com/users/seanmars/received_events","type":"User","site_admin":false},"created_at":"2018-06-05T02:55:33Z","updated_at":"2018-06-05T02:55:33Z","author_association":"NONE","body":"I change the level of `internal-nlog.log` to trace and add the file by gist.\r\nAnd i found it's doesn't matter the `NLog.LogManager.Shutdown()` is called or not.\r\nIf the use `NLog` it is 100% get exception."}}
{"actor":{"display_login":"seanmars"}}