Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetMQPoller Refuses to Stop - Bug? #598

Closed
peske opened this issue Aug 2, 2016 · 8 comments
Closed

NetMQPoller Refuses to Stop - Bug? #598

peske opened this issue Aug 2, 2016 · 8 comments
Labels

Comments

@peske
Copy link

peske commented Aug 2, 2016

Environment

NetMQ Version:    4.0.0-rc5
Operating System: Win 10 x64
.NET Version:     4.6.1

Expected behaviour

NetMQPoller should stop when Stop method is called.

Actual behaviour

NetMQPoller does not stop on Stop method call.

Steps to reproduce the behaviour

I'll provide code snippet:

class MyClass : IDisposable {
    private readonly NetMQPoller _poller = new NetMQPoller();
    private readonly NetMQTimer _pollTimeout = new NetMQTimer(TimeSpan.FromMilliseconds(50));
    private readonly PairSocket _subReceiver = new PairSocket();
    private readonly DealerSocket _receiver = new DealerSocket();

    MyClass() {
        _subReceiver.Bind("inproc://someaddress");
        _receiver.Connect("tcp://otheraddress");

        _receiver.ReceiveReady += Socket_ReceiveReady;
        _subReceiver.ReceiveReady += SubReceiver_ReceiveReady;
        _pollTimeout.Elapsed += PollTimeout_Elapsed;

        _poller.Add(_pollTimeout);
        _poller.Add(_receiver);
        _poller.Add(_subReceiver);
    }

    void Socket_ReceiveReady(object sender, NetMQSocketEventArgs e) {
       _poller.Stop();
    }

    void SubReceiver_ReceiveReady(object sender, NetMQSocketEventArgs e) {
        // Never happens!
       _poller.Stop();
    }

    void PollTimeout_Elapsed(object sender, NetMQTimerEventArgs e) {
        _poller.Stop();
    }

    void Iteration() {
        _pollTimeout.Interval = 50;
        _pollTimeout.EnableAndReset();

        _poller.Run();
    }

    void Dispose() {
        //...
    }
}

Method Iteration() is called by external code within the loop (the same thread).

There are several problems with this:

  1. SubReceiver_ReceiveReady is never called (ReceiveReady is never triggered) although messages are arriving to _subReceiver (PairSocket). I'm positive that messages are arriving because I'm able to receive them "manually" from within Iteration method body.
  2. _poller.Stop() successfully stops the poller few times (2-3), but after that not. What is happening after that is that PollTimeout_Elapsed gets called regularly, every time calling _poller.Stop(), but poller never gets stopped. (I've placed break points into all the methods and realized that only PollTimeout_Elapsed has any activity.)

Am I doing something wrong? Or it is a bug?

Thanks

@peske
Copy link
Author

peske commented Aug 3, 2016

Guyz, have you checked this? Is there a problem in my code?

Thanks!

@somdoron
Copy link
Member

somdoron commented Aug 4, 2016

It seems the poller is not very good at stopping and starting, I will ckeck it out

@peske
Copy link
Author

peske commented Aug 6, 2016

Doron, any news about this? Actually the thing that concerns me more than inability to stop the poller is the fact that SubReceiver_ReceiveReady is never called, meaning that ReceiveReady is never triggered. If it is true, it is huge - show-stopper bug in core functionality.

Meanwhile, if you have a few seconds I would appreciate if you take a look at zeromq/libzmq#2078 - it might happen that you can help in sentence or two...
(I've solved referenced issue meanwhile.)

Thanks

@somdoron
Copy link
Member

somdoron commented Aug 6, 2016

@peske the problem is you have to readd the sockets after each run of the poller, apparently the poller is removing all sockets after every run, we should probably fix this

@somdoron
Copy link
Member

somdoron commented Aug 6, 2016

@peske I'm exposing the internal class NetMQPoller is using to do the polling, the internal class API is exactly like the zmq_poll

@somdoron
Copy link
Member

somdoron commented Aug 6, 2016

@peske take a look at the following Pull Request:

#599

You can now use NetMQSelector, behavior exactly like zmq_poll

@peske
Copy link
Author

peske commented Aug 6, 2016

Thanks Doron! I'll give a shot and let you know.

@stale
Copy link

stale bot commented May 15, 2020

This issue has been automatically marked as stale because it has not had activity for 365 days. It will be closed if no further activity occurs within 56 days. Thank you for your contributions.

@stale stale bot added the stale label May 15, 2020
@stale stale bot closed this as completed Jul 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants