Closed jlouazel closed 3 years ago
I'm not sure what could cause this. Could you try sleeping maybe 10 ms around the line control.send(zmq::str_buffer("TERMINATE"), zmq::send_flags::none);
to check if this is some timing issues. If that fails you could try asking in libzmq.
I actually succeeded in reproducing it properly. I got an example of a client/server where the client will send an incrementing counter every second to the server through the router. If you run it, you'll be able to see that both the backend
and the capture
will get the message.
The problem, as stated in the original issue, is really in the deinitialization phase.
If we consider the code below:
you can reproduce the behavior of the router being stuck forever. Now the exciting part is when we change the order of the router being deinitialized:
And with this, it works! 🤔
In summary:
frontend
, backend
and capture
makes it hang indefinitelyAs a bonus, leaving the capture socket empty within the router seems to work as well! I suppose all of this trouble has something to do with this, but I cannot figure out why. Maybe your sharp eyes will be able to see something I didn't!
Ok thanks for that. I can image that sending the messages to the capture socket in the implementation is blocking and will block forever if the receiving side is closed before the proxy finishes? The implementation is non-trivial so I can't tell https://github.com/zeromq/libzmq/blob/master/src/proxy.cpp.
Anyway, I would suggest you post this to https://github.com/zeromq/libzmq to maybe to get expert take a look.
Thanks @gummif. As you suggested, I fixed this by making sure the capture is being deinitialized properly before the rest. That did the trick!
Hopefully, this thread can help people in the same situation to understand what's going on. As far as I'm concerned, we're done here.
@jlouazel Do you have a complete demo?
While using
zmq::proxy_steerable
, I've come across an interesting issue. Everything seems to work according to the documentation except when I plug a capture socket as well.So with a little bit of code, here's what's happening:
I'm using the following code from another thread to communicate my intent to close the proxy:
I'm using
cppzmq
4.7.1 on OSX, if that can pinpoint you to a more precise answer. I'm expecting in this situation to be able to benefit both from the capture and the control capabilities of the proxy. I'm just wondering if that is possible at all.Thanks in advance for your answers.