jzmq
jzmq copied to clipboard
org.zeromq.ZMQException: Socket operation on non-socket
I am using a DEALER-ROUTER socket combination with an in process endpoint to send messages within my application. Message is sent through a DEALER socket, received via the ROUTER socket. Both sockets are created by the same Context. Below is the code that handles receipt of messages from the ROUTER socket.
final byte[] identity = getSocket().recv();
final String senderId = new String(identity);
final LinkedList<byte[]> messageParts = new LinkedList<>();
messageParts.add(getSocket().recv());
while (getSocket().hasReceiveMore()) {
messageParts.add(getSocket().recv());
}
getLogger().info("Received Command from [{}] with part count [{}]", senderId, messageParts.size());
final ControlCommand command = getCodec().decode(messageParts);
command.execute(ioLoop);
getSocket().send(identity, ZMQ.SNDMORE);
getSocket().send("EXECUTED");
Immediately after reading the message, executing an action, it replies back. However, the first socket send is causing the following exception to be thrown.
org.zeromq.ZMQException: Socket operation on non-socket
at org.zeromq.ZMQ$Socket.send(Native Method) ~[jzmq-jni-0-SNAPSHOT.jar:${buildNumber} 2016-10-04 16:25 +0100]
at org.zeromq.ZMQ$Socket.send(ZMQ.java:1665) ~[jzmq-jni-0-SNAPSHOT.jar:${buildNumber} 2016-10-04 16:25 +0100]
Please can you help me understand what is wrong?
Can anyone help with this? Do I need to post more detail?
@armen @trevorbernard @saarons @ellisonbg @jleahy Can anyone help with this query?
I would also poll the zeromq mailing list. This error is coming from libzmq and being propagated as ZMQException.
I have subscribed to the mailing list. However I don't need to post this question anymore as I have figured out what the problem was.
What was the problem @jivk ? I have found this issue on many forums and am having this problem myself.
I think this message occurs whenever you try to do an operation on a socket that has been closed. Message is very misleading in that respect.