-
Notifications
You must be signed in to change notification settings - Fork 489
Closed
Description
I am writing a library that communicates with the ZeroMQ server of OpenNMT. This code works using 0.3.6, but hangs on the receiving using any 0.4.x branch.
public OpenNMTZeroMQClient(String host, int port) {
this.context = ZMQ.context(2);
this.socket = context.socket(ZMQ.REQ);
String hostAddress = "tcp://" + host + ":" + port;
LOG.info("Connecting to '{}'", hostAddress);
socket.connect(hostAddress);
}
public void translate(String text) {
String js = new JSONArray()
.put(new JSONObject()
.put("src", text))
.toString();
LOG.info("Sending '{}'...", js);
boolean wasSent = socket.send(js.getBytes(ZMQ.CHARSET), 0);
if(wasSent) {
LOG.info("Sent!");
}
LOG.info("Receiving...");
String reply = socket.recvStr();
LOG.info("Received: '{}'", reply);
}
public void close() {
if(this.socket != null) {
this.socket.close();
}
if(this.context != null) {
this.context.term();
}
}
It doesn't actually fail, but it just hangs on the recv() call. The server didn't receive anything, so the problem is probably that the send never happened.
EDIT: code formatting
Metadata
Metadata
Assignees
Labels
No labels