Reputation: 1031
I have implemented a simple client and a server using PUB/SUB in java using jeromq 0.3.2.
If I execute both programms locally, the client receives data. If I deploy the same client jar on a remote computer and run it, I don't receive any messages. The client using the ip of the server in both cases. No changes here for the remote deployment.
Firewall should not be an issue either, as the netstat excerpt below shows. The server (for test purpose my Macbook Air) does also not block any outgoing traffic.
Any hints? Somehow I'm not able to spot the error (probably something stupid, but too blind to see...)
Server.java
ZMQ.Context context = ZMQ.context(1);
ZMQ.Socket publisher = context.socket(ZMQ.PUB);
publisher.bind("tcp://*:5556");
Client.java
ZMQ.Context context = ZMQ.context(1);
ZMQ.Socket subscriber = zmqContext.socket(ZMQ.SUB);
subscriber.connect("tcp://192.168.178.21:5556");
subscriber.subscribe("".getBytes());
Firewall shouldn't be an issue either
netstat -a ] grep 5556
says
tcp 0 1 192.168.178.29:38145 192.168.178.21:5556 SYN_SENT
Finally my iptables config, just in case I made a stupid configuration mistake here.
*filter
:INPUT DROP [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [1161:105847]
-A INPUT -i lo -j ACCEPT
-A INPUT -s 192.168.178.0/24 -j ACCEPT
COMMIT
Upvotes: 2
Views: 743
Reputation: 1031
In fact the problem was not with the code or the firewall on the client.
My emitting computer (Macbook Air) had a firewall rule active, which did not allow any incoming connections. That's why the connection always stuck in SYN_SENT. I've overlooked this when examining the firewall rules.
A general advise I received for tracing connection related problems with 0mq (or tcp in general) on *nix based systeme: tcpdump, ngrep, netcat
Upvotes: 1