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

Issue with ZMQ_RECONNECT_STOP_AFTER_DISCONNECT option #4720

Closed
githejie opened this issue Aug 9, 2024 · 0 comments · Fixed by #4721
Closed

Issue with ZMQ_RECONNECT_STOP_AFTER_DISCONNECT option #4720

githejie opened this issue Aug 9, 2024 · 0 comments · Fixed by #4721

Comments

@githejie
Copy link
Contributor

githejie commented Aug 9, 2024

Issue description

The description of ZMQ_RECONNECT_STOP_AFTER_DISCONNECT in the zeromq documentation is:
The 'ZMQ_RECONNECT_STOP_AFTER_DISCONNECT' option will stop reconnection when
zmq_disconnect() has been called. This can be useful when the user's request failed
(server not ready), as the socket does not need to continue to reconnect after
user disconnect actively. (https://zeromq.github.io/libzmq/zmq_setsockopt.html)

However, in actual testing, I found that after the socket set the ZMQ_RECONNECT_STOP_AFTER_DISCONNECT option, there is a probability that the reconnection will be abandoned before calling zmq_disconnect.

int stopReconnectOnError = ZMQ_RECONNECT_STOP_AFTER_DISCONNECT;
zmq_setsockopt (sock, ZMQ_RECONNECT_STOP, &stopReconnectOnError, sizeof (stopReconnectOnError));
zmq_connect (sub, "ipc://@dummy");
print_events (sub_mon, 2 * 1000, 10);
zmq_disconnect (sub, "ipc://@dummy");
print_events (sub_mon, 2 * 1000, 10);

For the test code above, we expect to see output like this:

Got event: CLOSED
Got event: CONNECT_RETRIED
Got event: CLOSED
Got event: CONNECT_RETRIED
Got event: CLOSED
Got event: CONNECT_RETRIED
Got event: CLOSED
Got event: CONNECT_RETRIED
Got event: CLOSED
Got event: CLOSED
Still waiting for monitor event after 250 ms
Still waiting for monitor event after 500 ms
Still waiting for monitor event after 750 ms
Still waiting for monitor event after 1000 ms

When this problem occurs, the output is like this:

Got event: CLOSED
Still waiting for monitor event after 250 ms
Still waiting for monitor event after 500 ms
Still waiting for monitor event after 750 ms
Still waiting for monitor event after 1000 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant