Does ZeroMQ/czmq fail once creating too many [ inproc:// ] connections? -
i have set of producers , consumers, both of implemented zactors
. consumers bind inproc
endpoints, , each producer connects every other consumer.
at 1 point, seems zeromq
cannot create more sockets or connections ( not sure ).
minimal working example:
#include "czmq.h" void source_t(zsock_t * pipe, void *args); void sink_t(zsock_t * pipe, void *args); int main(int argc, char *argv[]){ zsys_init(); printf("max sockets = %d\n", zsys_socket_limit()); int num_sources = atoi(argv[1]); int num_sinks = atoi(argv[2]); /** create sinks */ zactor_t *sinks[num_sources]; (int = 0; < num_sources; i++){ sinks[i] = zactor_new(sink_t, (void *)(&i)); assert(sinks[i]); } /** create sources */ zactor_t *sources[num_sources]; (int = 0; < num_sources; i++){ sources[i] = zactor_new(source_t, (void *)(&i)); assert(sources[i]); zsock_send(sources[i], "i", num_sinks); zsock_wait(sources[i]); } return 0; } void source_t(zsock_t * pipe, void *args){ const int id = *((int *)args); zsock_signal(pipe, 0); int num_sinks; zsock_recv(pipe, "i", &num_sinks); zsock_t * transmitters[num_sinks]; (int = 0; < num_sinks; i++){ transmitters[i] = zsock_new(zmq_push); if(transmitters[i] == null){ printf( "source %d not create socket %d because %s\n", id, i, strerror(errno) ); assert(false); ////// here's fails ___________________ } int rc = zsock_connect(transmitters[i], "inproc://snk%d", i); if (rc != 0){ printf("source %d not connect sink %d because %s\n", id, i, strerror(errno)); assert(false); } } zsock_signal(pipe, 0); } void sink_t(zsock_t * pipe, void *args){ const int id = *((int *)args); zsock_t * receiver = zsock_new(zmq_pull); assert(receiver); int rc = zsock_bind(receiver, "inproc://snk%d", id); assert(rc == 0); zsock_signal(pipe, 0); while (true){ zsock_recv(receiver, "z"); } }
i ran on linux 30 producers , 30 consumers , failed. open files limit 6144.
here's output:
$ zproctest 30 30 max sockets = 65535 source 29 not create socket 4 because socket operation on non-socket zproctest: ../src/zproctest.cpp:43: void source_t(zsock_t*, void*): assertion `false' failed. aborted
is there else has faced similar issue or can shed light on it?
Comments
Post a Comment