{"action":"created","issue":{"url":"https://api.github.com/repos/zeromq/netmq/issues/230","labels_url":"https://api.github.com/repos/zeromq/netmq/issues/230/labels{/name}","comments_url":"https://api.github.com/repos/zeromq/netmq/issues/230/comments","events_url":"https://api.github.com/repos/zeromq/netmq/issues/230/events","html_url":"https://github.com/zeromq/netmq/issues/230","id":58091270,"number":230,"title":"HelloWorld hangs in Context.Dispose on Unity","user":{"login":"barzto","id":10025111,"avatar_url":"https://avatars.githubusercontent.com/u/10025111?v=3","gravatar_id":"","url":"https://api.github.com/users/barzto","html_url":"https://github.com/barzto","followers_url":"https://api.github.com/users/barzto/followers","following_url":"https://api.github.com/users/barzto/following{/other_user}","gists_url":"https://api.github.com/users/barzto/gists{/gist_id}","starred_url":"https://api.github.com/users/barzto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/barzto/subscriptions","organizations_url":"https://api.github.com/users/barzto/orgs","repos_url":"https://api.github.com/users/barzto/repos","events_url":"https://api.github.com/users/barzto/events{/privacy}","received_events_url":"https://api.github.com/users/barzto/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":18,"created_at":"2015-02-18T16:32:07Z","updated_at":"2015-07-23T13:57:14Z","closed_at":null,"body":"Hi guys,\r\n\r\nI've got this code derived from HelloWorld example\r\n\r\n```C#\r\nprivate static void TestNetMQ()\r\n{\r\n    using (NetMQContext ctx = NetMQContext.Create())\r\n    {\r\n        using (var server = ctx.CreateResponseSocket())\r\n        {\r\n            server.Bind(\"tcp://127.0.0.1:5556\");\r\n            \r\n            using (var client = ctx.CreateRequestSocket())\r\n            {\r\n                client.Connect(\"tcp://127.0.0.1:5556\");\r\n                client.Send(\"Hello\");\r\n                string m1 = server.ReceiveString();\r\n                server.Send(\"Hi Back\");\r\n                string m2 = client.ReceiveString();\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n```\r\n\r\nWhen I run it in standalone Mono installed form MacPorts on OSX, it runs without any issue, but when I run it in Unity Editor, it hangs when disposing context. I've tracked down the place  where main-thread gets dead-locked:\r\n\r\n```\r\nSystem.Net.Sockets.Socket.Poll (time_us=-1000, mode=The requested item has been unloaded.) in \r\nNetMQ.zmq.Utils.Signaler.WaitEvent (timeout=-1) in .../Assets/Scripts/ThirdParty/NetMQ/src/zmq/Utils/Signaler.cs:118\r\nNetMQ.zmq.Mailbox.Recv (timeout=-1) in .../Assets/Scripts/ThirdParty/NetMQ/src/zmq/Mailbox.cs:208\r\nNetMQ.zmq.Ctx.Terminate () in .../Assets/Scripts/ThirdParty/NetMQ/src/zmq/Ctx.cs:209\r\nNetMQ.NetMQContext.Terminate () in .../Assets/Scripts/ThirdParty/NetMQ/src/NetMQContext.cs:267\r\nNetMQ.NetMQContext.Dispose () in .../Assets/Scripts/ThirdParty/NetMQ/src/NetMQContext.cs:273\r\n```\r\n\r\nThe standalone mono's --version is:\r\n```\r\nMono JIT compiler version 3.12.0 ((detached/de2f33f Mon Feb  2 14:42:07 EST 2015)\r\nCopyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com\r\n\tTLS:           normal\r\n\tSIGSEGV:       altstack\r\n\tNotification:  kqueue\r\n\tArchitecture:  x86\r\n\tDisabled:      none\r\n\tMisc:          softdebug \r\n\tLLVM:          yes(3.6.0svn-mono-(detached/5486eb2)\r\n\tGC:            sgen\r\n```\r\n\r\nThe Unity editor's mono is:\r\n\r\n```\r\nMono JIT compiler version 2.6.5 (tarball Mon Jan 19 16:08:20 CET 2015)\r\nCopyright (C) 2002-2010 Novell, Inc and Contributors. www.mono-project.com\r\n\tTLS:           normal\r\n\tGC:            Included Boehm (with typed GC)\r\n\tSIGSEGV:       normal\r\n\tNotification:  Thread + polling\r\n\tArchitecture:  x86\r\n\tDisabled:      none\r\n```\r\nBoth running OSX 10.9.\r\n\r\nAny idea what can go wrong here? Any good place to put breakpoint, log etc.?\r\n\r\nCheers,\r\n-Jan"},"comment":{"url":"https://api.github.com/repos/zeromq/netmq/issues/comments/124116622","html_url":"https://github.com/zeromq/netmq/issues/230#issuecomment-124116622","issue_url":"https://api.github.com/repos/zeromq/netmq/issues/230","id":124116622,"user":{"login":"somdoron","id":2715638,"avatar_url":"https://avatars.githubusercontent.com/u/2715638?v=3","gravatar_id":"","url":"https://api.github.com/users/somdoron","html_url":"https://github.com/somdoron","followers_url":"https://api.github.com/users/somdoron/followers","following_url":"https://api.github.com/users/somdoron/following{/other_user}","gists_url":"https://api.github.com/users/somdoron/gists{/gist_id}","starred_url":"https://api.github.com/users/somdoron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/somdoron/subscriptions","organizations_url":"https://api.github.com/users/somdoron/orgs","repos_url":"https://api.github.com/users/somdoron/repos","events_url":"https://api.github.com/users/somdoron/events{/privacy}","received_events_url":"https://api.github.com/users/somdoron/received_events","type":"User","site_admin":false},"created_at":"2015-07-23T13:57:14Z","updated_at":"2015-07-23T13:57:14Z","body":"When context hangs it is usually a sign that one of the sockets was not\nclosed properly.\n\nFew solutions for this:\n* Find out which socket is causing the problem\n* Don't close the context, application will just die\n* A new feature to close the context even if sockets are still alive.\n\nOn Thu, Jul 23, 2015 at 4:55 PM, Doron Somech <somdoron@gmail.com> wrote:\n\n> Did you try the ForceDotNet.Force(); at the beginning of the application?\n>\n> On Thu, Jul 23, 2015 at 4:47 PM, Sokharev <notifications@github.com>\n> wrote:\n>\n>> Hello, I've expirienced the same problem in Unity (connect/send/dispose\n>> context hangs) with latest version and found problem in Ctx.cs in method\n>> Terminate(). I'am not sure that it's \"right\" but in my case it hangs in\n>> this line:\n>>\n>> Command cmd = m_termMailbox.Recv(-1);\n>>\n>> if've wrapped it with final \"Poll\" ( but for sure it's dirty & hacky )\n>> and Unity Editor works ok now(no hangs)\n>>\n>> if( m_termMailbox.Handle.Poll( 100, System.Net.Sockets.SelectMode.SelectRead ) )\n>> {\n>>     if (m_termMailbox.Handle.Connected)\n>>        {\n>>          Command cmd = m_termMailbox.Recv(-1);\n>>          Debug.Assert(cmd != null);\n>>          Debug.Assert(cmd.CommandType == CommandType.Done);\n>>         }\n>> }\n>>\n>> @somdoron <https://github.com/somdoron> Could you please comment how to\n>> fix in right manner?\n>>\n>> —\n>> Reply to this email directly or view it on GitHub\n>> <https://github.com/zeromq/netmq/issues/230#issuecomment-124109655>.\n>>\n>\n>\n"}}