[zeromq-dev] "too many open files" error in zmq/jzmq
Pieter Hintjens
pieterh at gmail.com
Sat Sep 10 23:51:44 CEST 2011
I guess you're using an out of date version of 0MQ. This limit is gone in
the latest stable release.
-Pieter
On Sep 8, 2011 3:03 PM, "Igor 'Lo' (И.L.)" <
bombsiteunrested at gmail.com> wrote:
> Hi all.
>
> What can cause an REQ/REP pair to crash (after doing multiple requests
> from Java to C++, crashing both sides at random choice) with following
> message:
>
> Too many open files
> rc == 0 (mailbox.cpp:375)
> (END)
>
> C++ side:
>
> zmq::context_t context (1);
> zmq::socket_t socket (context, ZMQ_REP);
> socket.bind ("tcp:://localhost:1234);
>
> while (true) {
> void *context = zmq_init(1);
> zmq::message_t *request = new zmq::message_t;
> socket.recv (request);
> ... // parse request, prepare reply: unsigned char data with length dsize
> zmq::message_t reply (dsize+1);
> memcpy((void *)reply.data(), &data, dsize);
> memset((void *)reply.data()+dsize, '\0', 1);
> socket.send(reply);
> }
>
> Java side:
>
> ZMQ.Context context = ZMQ.context(1);
> ZMQ.Socket jsocket = context.socket(ZMQ.REQ);
> jsocket.connect ("tcp://localhost:1234");
> jsocket.send(req, 0);
> ZMQ.Poller it = context.poller(1);
> it.setTimeout(2*1000000);
> it.register(jsocket, ZMQ.Poller.POLLIN);
> if (it.pollin(0)) {
> byte[] reply = jsocket.recv(0);
> ... // parse reply
> }
> jsocket.close();
>
> Java can call the above code from multiple threads.
> I suspect the handbook didn't told me how to close used resources in a
> correct way.. shouldn't something be done upon zmq::message_t or with
> zmq::context? I thought that scope exit at loop should've been
> destroying them..
>
> --
> cheers,
> Igor
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110910/483120a6/attachment.htm>
More information about the zeromq-dev
mailing list