2
votes

My program uses ZMQ for communication. Namely, a server (C++, linux) creates an XPUB socket and then in one thread reads it, and in another one publishes data (writes).

The client (java, jzmq, linux) create a SUB socket, and subscribes using it.

After some time, the server side receives SIGABRT in the reading thread.

What may be a source of problem? Read/Write in different threads or creating XPUB/SUB pair?

In case the problem is in multi threading, what is a right paradigm to use XPUB socket?

1
StackOverflow encourages to formulate high-quality questions by a convention of MCVE-code, that demonstrates the problem asked about. Not doing so leaves other just a change to guess. Feel free to update the post with such MCVE-code. ZeroMQ is great in building both a distributed ( non-shared ), and smart-shared ( central ) Context()-instance fabricated socket Scalable Formal Communication Archetype-rich signalling / messaging layers, but asking what caused SIGABRT in some of my code deployment is suited more for a Clairvoyance-site, than for a StackOverflow Community of Knowledge, ok?user3666197

1 Answers

4
votes

http://zguide.zeromq.org/page:all#Multithreading-with-ZeroMQ

Don't share ZeroMQ sockets between threads. ZeroMQ sockets are not threadsafe. Technically it's possible to migrate a socket from one thread to another but it demands skill. The only place where it's remotely sane to share sockets between threads are in language bindings that need to do magic like garbage collection on sockets.