jzmq icon indicating copy to clipboard operation
jzmq copied to clipboard

org.zeromq.ZMQException: Socket operation on non-socket

Open jivk opened this issue 8 years ago • 6 comments

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?

jivk avatar Nov 17 '16 10:11 jivk

Can anyone help with this? Do I need to post more detail?

jivk avatar Nov 23 '16 17:11 jivk

@armen @trevorbernard @saarons @ellisonbg @jleahy Can anyone help with this query?

jivk avatar Nov 24 '16 17:11 jivk

I would also poll the zeromq mailing list. This error is coming from libzmq and being propagated as ZMQException.

trevorbernard avatar Nov 24 '16 20:11 trevorbernard

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.

jivk avatar Nov 25 '16 21:11 jivk

What was the problem @jivk ? I have found this issue on many forums and am having this problem myself.

TheMaverickProgrammer avatar Feb 12 '17 01:02 TheMaverickProgrammer

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.

jivk avatar Feb 16 '17 17:02 jivk