Open awaited-hare opened 4 years ago
Currently the linger period is disabled for all socket using the ZMQ_BLOCKY
socket option. I swear I documented the default socket options that I used somewhere but I can't find it in the doc.
If you have a valid use case, we could expose this API publicly.
However I don't think that your example use case is a valid use because of the nature of the gather and scatter transport. ZMQ provides no synchronization mechanism for PUB & SUB nor GATHER & SCATTER because "the data stream is [considered] infinite and has no start and no end and therefore cannot be used for reliable messaging. That's why messages are dropped on a slow subscriber (albeit that behavior can be configured).
The way the ZMQ guide suggest to do the sync is to either sleep a given amount of time (which is a terrible idea) or use another reliable socket to do the sync (which i think is equally terrible). I think the ideal solution would be for the Scatter socket to be notified when a Gather socket subscribes, but thats out of the scope of ZMQ I'm afraid.
I'll add some clarification on the default behavior in the libzmq::prelude::Socket
doc.
Describe the bug A clear and concise description of what the bug is.
libzmq
does not ensure all messages are sent before socket is dropped.To Reproduce Give a minimal reproduction example of the bug, if applicable.
The following code hangs:
Expected behavior A clear and concise description of what you expected to happen.
The messages should be sent before the socket is dropped.
Platform: