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
[email protected] <mailto:[email protected]>
NANTES  logo_xiwengames <http://www.xiwengames.com>

_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to