{"action":"created","issue":{"url":"https://api.github.com/repos/zeromq/netmq/issues/383","labels_url":"https://api.github.com/repos/zeromq/netmq/issues/383/labels{/name}","comments_url":"https://api.github.com/repos/zeromq/netmq/issues/383/comments","events_url":"https://api.github.com/repos/zeromq/netmq/issues/383/events","html_url":"https://github.com/zeromq/netmq/issues/383","id":105330542,"number":383,"title":"Rare hanging on network blips","user":{"login":"ashic","id":565991,"avatar_url":"https://avatars.githubusercontent.com/u/565991?v=3","gravatar_id":"","url":"https://api.github.com/users/ashic","html_url":"https://github.com/ashic","followers_url":"https://api.github.com/users/ashic/followers","following_url":"https://api.github.com/users/ashic/following{/other_user}","gists_url":"https://api.github.com/users/ashic/gists{/gist_id}","starred_url":"https://api.github.com/users/ashic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashic/subscriptions","organizations_url":"https://api.github.com/users/ashic/orgs","repos_url":"https://api.github.com/users/ashic/repos","events_url":"https://api.github.com/users/ashic/events{/privacy}","received_events_url":"https://api.github.com/users/ashic/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-09-08T08:43:26Z","updated_at":"2015-09-08T13:52:49Z","closed_at":null,"body":"I've got some services running on Windows. Usually they're all fine. In case of sustained multiple consecutive failures, the services are configured to shutdown (so an external supervisor can kick them). However, Disposing contexts seem to be...interesting. The common pattern for my services are:\r\n\r\n```\r\npublic class Something : IDisposable\r\n{\r\n    ctor(){Initializes NetMQContext}\r\n    public async Task Run(){\r\n        //creates a CancellationTokenSource.\r\n       //Task.Factory.StartNew(...). In task:\r\n       // creates socket\r\n        //spins while it's false doing socket receive/send\r\n    }\r\n\r\n    bool _disposed;\r\n    Dispose(){\r\n        if(_disposed) return;\r\n        _disposed = true;\r\n       _cancel.Cancel();\r\n       context.Dispose();\r\n    }\r\n}\r\n```\r\n\r\nNow depending on which thread disposal happens in, the Context dispose can *sometimes* hang. During normal ops, this doesn't seem to much often, but in case of network blips and the service shutting down, I get a \"Service stuck in a stopping state\" issue. I've pinpointed it down to the context.Dispose() hanging. \r\n\r\nIs there some way to tell NetMQ - \"hey yo - I'm dying now. Can you please just go away\"? Or is there some other pattern to use?"},"comment":{"url":"https://api.github.com/repos/zeromq/netmq/issues/comments/138566424","html_url":"https://github.com/zeromq/netmq/issues/383#issuecomment-138566424","issue_url":"https://api.github.com/repos/zeromq/netmq/issues/383","id":138566424,"user":{"login":"ashic","id":565991,"avatar_url":"https://avatars.githubusercontent.com/u/565991?v=3","gravatar_id":"","url":"https://api.github.com/users/ashic","html_url":"https://github.com/ashic","followers_url":"https://api.github.com/users/ashic/followers","following_url":"https://api.github.com/users/ashic/following{/other_user}","gists_url":"https://api.github.com/users/ashic/gists{/gist_id}","starred_url":"https://api.github.com/users/ashic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashic/subscriptions","organizations_url":"https://api.github.com/users/ashic/orgs","repos_url":"https://api.github.com/users/ashic/repos","events_url":"https://api.github.com/users/ashic/events{/privacy}","received_events_url":"https://api.github.com/users/ashic/received_events","type":"User","site_admin":false},"created_at":"2015-09-08T13:52:49Z","updated_at":"2015-09-08T13:52:49Z","body":"I've already identified that the line in question is context.Dispose(). There's some socket doing some outstanding work, it seems. But when it hangs, it's always on context.Dispose(). It triggers that line, and stall everything."}}