Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPC with unix domain socket no communication #482

Open
Cjen1 opened this issue Aug 6, 2019 · 3 comments
Open

IPC with unix domain socket no communication #482

Cjen1 opened this issue Aug 6, 2019 · 3 comments

Comments

@Cjen1
Copy link

Cjen1 commented Aug 6, 2019

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.

@changetoblow
Copy link

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

@Cjen1
Copy link
Author

Cjen1 commented Feb 26, 2020

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

@changetoblow
Copy link

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants