Closed yeowgit closed 9 years ago
I think your problem is that the context get terminated, find the place you dispose the context, you might dispose it too early while the beacon is still running. To try to solve remove the context dispose command (or remove using), and see if you still have the problem
On Wed, May 13, 2015 at 6:38 PM, yeowgit notifications@github.com wrote:
Hi,
I am experimenting with beacon using the tutorial from the doc, http://netmq.readthedocs.org/en/latest/beacon/
I copy the code from the doc page, with a change to send a message via shim if a disconnection is detected. I have two nodes connecting to each other. When one of the node is disconnected, I get below stack trace (on NetMQPollerThread) on the node that is still alive.
at NetMQ.Core.SocketBase.CheckContextTerminated() in c:\work\net0mq\netmq-latest\src\NetMQ\Core\SocketBase.cs:line 134 at NetMQ.Core.SocketBase.SetSocketOption(ZmqSocketOption option, Object optionValue) in c:\work\net0mq\netmq-latest\src\NetMQ\Core\SocketBase.cs:line 286 at NetMQ.NetMQSocket.SetSocketOption(ZmqSocketOption option, Int32 value) in c:\work\net0mq\netmq-latest\src\NetMQ\NetMQSocket.cs:line 541 at NetMQ.NetMQSocket.SetSocketOptionTimeSpan(ZmqSocketOption option, TimeSpan value) in c:\work\net0mq\netmq-latest\src\NetMQ\NetMQSocket.cs:line 552 at NetMQ.SocketOptions.set_SendTimeout(TimeSpan value) in c:\work\net0mq\netmq-latest\src\NetMQ\SocketOptions.cs:line 254 at NetMQ.NetMQActor.RunShim() in c:\work\net0mq\netmq-latest\src\NetMQ\NetMQActor.cs:line 229 at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
Below is the change to code in doc: private void ClearDeadNodes(object sender, NetMQTimerEventArgs e) { // create an array with the dead nodes var deadNodes = m_nodes. Where(n => DateTime.Now > n.Value + DeadNodeTimeout). Select(n => n.Key).ToArray();
// remove all the dead nodes from the nodes list and disconnect // from the publisher foreach (var node in deadNodes) { m_nodes.Remove(node); m_publisher.Disconnect( string.Format("tcp://{0}:{1}", node.Name, node.Port)); m_shim.Send("bah"); <-- get exception Context is terminated }
}
Thanks
— Reply to this email directly or view it on GitHub https://github.com/zeromq/netmq/issues/341.
Problem solved. Unhanded exception was thrown elsewhere causing this problem after OnShimReady handler was invoked. I think I got Beacon working as intended for now. Thanks.
Hi,
I am experimenting with beacon using the tutorial from the doc, http://netmq.readthedocs.org/en/latest/beacon/
I copy the code from the doc page, with a change to send a message via shim if a disconnection is detected. I have two nodes connecting to each other. When one of the node is disconnected, I get below stack trace (on NetMQPollerThread) on the node that is still alive.
Below is the change to code in doc:
Thanks