[zeromq-dev] Possible bug in ZMQ HWM handling?

Francesco francesco.montorsi at gmail.com
Tue Sep 4 10:26:56 CEST 2018

Hi all,
Just to follow up on this: I discovered the reason why HWM were apparently
not working on the setup I described on my first email.
The reason is the following: in my setup the ZMQ proxy backend socket is a
TCP socket.
Now I discovered that when using the TCP transport, then if you set HWM=100
on the socket, you cannot expect the zmq_msg_send() to block on the 101-th
message: the reason is that the socket will block only if both ZMQ pipes
and kernel TCP buffers are full. Depending on the size of the TCP buffer,
that may happen after a lot more messages than 100.

Anyway I think that ZMQ HWM hanlding is not very clear and well documented.
I found some tickets still in OPEN status about this:

So I spent some time extending existing HWM unit test and creating a new
one to stress the ZMQ proxy when its HWM is reached.
I just created a work-in-progress PR here:

If maintainers can take a look and let me know what they think, I can
complete that PR and put it in a form where it can be merged...


Il giorno ven 31 ago 2018 alle ore 19:36 Francesco <
francesco.montorsi at gmail.com> ha scritto:

> I forgot to specify: this happens with ZeroMQ 4.2.3 on Linux.
> Il giorno ven 31 ago 2018 alle ore 18:54 Francesco <
> francesco.montorsi at gmail.com> ha scritto:
>> Hi all,
>> I spent quite a bit of time to look into a weird issue.
>> Here's my setup:
>>      1 PUB socket  connected to a STEERABLE PROXY FRONTED socket, using
>> INPROC transport
>>      1 SUB socket  connected to the STEERABLE PROXY BACKEND socket, using
>> TCP transport
>> Before starting stuff (i.e. calling zmq_connect() or zmq_bind()) I lower
>> all HWMs (for both TX/RX) of all sockets to just "10".  Moreover I set
>> Now my expected behaviour is that after 20 messages sent from the PUB
>> socket, the zmq_send() on that PUB becomes blocking.
>> You may argue that since I have the XPUB/XSUB sockets of the proxy in the
>> middle, the value after it becomes blocking is 40. That's ok.
>> The experimental result I found is that the PUB NEVER becomes blocking.
>> If I send 10000 messages from the PUB they all go through.
>> In the SUB I sleep 1 second after EVERY message received. It takes a
>> while but in the end the SUB receives all the 10000 messages...
>> Is there an explanation for this? Who buffered all those messages
>> (against my will) ?
>> Thanks for any hint!
>> Francesco
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20180904/dbeb4295/attachment.htm>

More information about the zeromq-dev mailing list