[zeromq-dev] CZMQ guaranteed delivery

Brett Viren brett.viren at gmail.com
Thu May 14 20:52:07 CEST 2020

Hi Johnny,

Johnny Depp <sdusa at hotmail.com> writes:

>  zstr_send(client, json_string);

This returns an int which -1 will indicate some kind of error.
zstr_send() wraps a lot of functionality so -1 can mean one of a few
things went wrong.  In any case, checking and acting on it would be part
of guaranteeing delivery.

> If the client sends 1000 messages, the server handles them with aplomb
> and all is well. However, if the client sends 10000 messages, about
> 1000 are lost. The client pauses from time to time while sending, but
> the server loses messages.

I guess the change of behavior at 1000 is a likely indication of filling
a socket buffer up to the default HWM of 1000.  

> I undrstand that while handling json messages, there is a delay. But
> regardless of that, even if this would be a simple send and receive,
> how can I guarantee delivery? Is there another mechanism or pattern
> that I should employ? Adding more server reading threads would help
> with this? Is there a way of buffering?

You can increase the HWM.  But, that tight send loop likely will always
run faster than the recv loop.  I guess HWM will always eventually be
reached in this test regardless of the HWM.

You don't mention the socket types being used.  If sender "client" means
"CLIENT" then the send loop should block on HWM which by itself should
guarantee eventual delivery.  So, I guess some other socket is being


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 865 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20200514/9d1f00dd/attachment.sig>

More information about the zeromq-dev mailing list