jzmq icon indicating copy to clipboard operation
jzmq copied to clipboard

IPC with unix domain socket no communication

Open Cjen1 opened this issue 6 years ago • 3 comments

I have a java client (REQ) trying to communicate with a (REP) python client via a mutually read/writeable unix domain socket

The java client appears to be able to write to the socket, however what it writes is never received by the python client.

The java client is as follows:

    public static void main(String[] args) throws Exception {
        String address = "/address"
        System.out.println("CLIENT: Parsed Address: " + address);

        ZMQ.Context context = ZMQ.context(1);
        ZMQ.Socket socket = context.socket(SocketType.REQ);

        address = "ipc://" + address;
        socket.connect( address );
        System.out.println("CLIENT: Connected to " + address);
        for(int i = 0; i < 5; i++){
            socket.send("Ping " + i);
            System.out.println("CLIENT: Sent.");
            String rep = new String(socket.recv());
            System.out.println("Reply " + i + ": " + rep);
        }
        socket.close();
        context.term();
    }

The python client is:

def run_client(clients, config):
    #--- Setup ----------
    #socket = zmq.Context().socket(zmq.ROUTER)
    socket = zmq.Context().socket(zmq.REP)

    runner_address = "ipc://"+config['runner_address']
    clean_address(runner_address) # Unlinks previous socket
    os.umask(0o000) # Ensures correct permissions
    socket.bind(runner_address)

    for i in range(5):
        print('Ponging' )
        r = socket.recv()
        print('Ponged ' + r)
        socket.send(r + " " + i)
    socket.close()

There might be a version mismatch between these being the issue since the python client is apparently: 4.3.1; while the java client is apparently 4.1.7.

Reading the documentation that shouldn't be the issue, however more info to help.

I am fairly sure that this is a jzmq specific issue since a python client in place of the java one works as expected.

Cjen1 avatar Aug 06 '19 14:08 Cjen1

@Cjen1 Hello, I met the same problem, have you solved it?

changetoblow avatar Feb 26 '20 02:02 changetoblow

@changetoblow I worked around it via the loopback address, unfortunately...

Cjen1 avatar Feb 26 '20 22:02 Cjen1

@Cjen1 Hello, I have some questions about JZMQ now, I hope to get your help. I originally used jeromq but jeromq does not support Unix domains with other languages, so I'm going to use JZMQ. I compiled JZMQ.There are two DLLS and a jar, I then added JZMQ's jar and DLL directly to the project, but there were still some class errors, For example, in your example above, sockettype.req in the Java code 'zmq.socket Socket = context.socket(sockettype.req)', Can you help me out?Thank you very much

changetoblow avatar Feb 27 '20 07:02 changetoblow