[zeromq-dev] Unsettling behaviour on ZMQ_STREAM sockets
Julien SOSTHENE
j.sosthene at xiwengames.com
Wed Dec 3 13:26:47 CET 2014
Hi!
I just want to report a somewhat unsettling behaviour on ZMQ_STREAM
sockets on ZeroMQ 4.0.5 :
I have been using ZeroMQ in C++ for quite a while now, I just noticed
something strange.
When you open too many external connections on a ZMQ_STREAM socket
without (ever) closing them, here is what happens with new connections:
- Input streams are processed normally and sent to backend (if any).
- If I try to send a response through that connection (using the
connection identity frame), zmq_msg_send() returns the effective size of
the message (or message part) but the message is never received by the
peer (blocked on receive(), with 0 bytes although ZeroMQ has already
returned the number of bytes that were supposed to be sent).
I had some trouble finding out where the problem came from since
zmq_msg_send() did not ever return -1 and acted as if everything was fine.
I had this problem because I hadn't understood how to close connections
properly, and thought naively that client-side closing would suffice.
The real way to close connections is documented here :
http://api.zeromq.org/4-0:zmq-socket in the ZMQ_STREAM section, however,
the "ZMQ_SNDMORE" flag must be set to 1 even if we send an empty frame
to close the connection, which is maybe a bit tough to undersand in the
documentation. Actually, I got it by reading the comment:
|/* NOTE: If we don't use ZMQ_SNDMORE, then we won't be able to send more */
/* message to any client */|
which is in the example code, but would probably have its place in the
main text since it is a bit counter-intuitive in my opinion :)
I thought it would be useful to point out.
Have a great day!
||
--
*Julien SOSTHENE*
Programmer
+33 6 33 444 999
j.sosthene at xiwengames.com <mailto:j.sosthene at xiwengames.com>
NANTES logo_xiwengames <http://www.xiwengames.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20141203/7b8f59c5/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Xiwen-inbox.gif
Type: image/gif
Size: 7907 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20141203/7b8f59c5/attachment.gif>
More information about the zeromq-dev
mailing list