<p>I am trying to connect to a bitcoin node using the ZMQ library for Java. the problem is that when I try to receive a response the code remains frozen. Returns nothing.</p>

<p>This is my code:</p>

<pre><code>public class CBETest {

    private static final String TEST_URL = "obelisk.airbitz.co";

    public static void main(String[] args) {

       System.out.println("\t--- ZMQ ---");
       Ctx c = zmq.ZMQ.createContext();
       SocketBase s = c.createSocket(zmq.ZMQ.ZMQ_DEALER);

       zmq.ZMQ.connect(s, "tcp://"+TEST_URL+":9091");
       System.out.println("Connected!");
       int sent = zmq.ZMQ.send(s, "blockchain.fetch_last_height", 0);

       System.out.println("Sent: " + sent);
       Msg msg = zmq.ZMQ.recv(s, 0);
       System.out.println("Response " + Arrays.toString(msg.data()));
    }
}
</code></pre>

<p>The code freezes in the line <code>Msg msg = zmq.ZMQ.recv(s, 0);</code>. I am using the calls described <a href="https://github.com/libbitcoin/libbitcoin-server/blob/master/doc/prot-sphinx/api.rst" rel="nofollow">here</a> for the full node implemetation. Thanks in advance!</p>

CC BY-SA 3.0
2016-01-04T12:17:10.850Z
Double check, if you have started bitcoind with `-zmqpubhashtx=tcp://<ip>:<port>` and or `-zmqpubhashblock=tcp://<ip>:<port>`.
Jonas Schnelli
CC BY-SA 3.0
2016-01-04T12:17:43.630Z
Also check https://github.com/bitcoin/bitcoin/blob/master/qa/rpc-tests/zmq_test.py   and keep in mind: zmq.ZMQ.recv does block your thread until bitcoind sends a block or tx.
Jonas Schnelli
<client><api><java><full-node><zeromq>
Library ZMQ to Java does not work
Ander Acosta
# Library ZMQ to Java does not work

(Asked by: username_0 on 2016-01-04)

I am trying to connect to a bitcoin node using the ZMQ library for Java. the problem is that when I try to receive a response the code remains frozen. Returns nothing.

This is my code:

```
public class CBETest {

    private static final String TEST_URL = "obelisk.airbitz.co";

    public static void main(String[] args) {

       System.out.println("\t--- ZMQ ---");
       Ctx c = zmq.ZMQ.createContext();
       SocketBase s = c.createSocket(zmq.ZMQ.ZMQ_DEALER);

       zmq.ZMQ.connect(s, "tcp://"+TEST_URL+":9091");
       System.out.println("Connected!");
       int sent = zmq.ZMQ.send(s, "blockchain.fetch_last_height", 0);

       System.out.println("Sent: " + sent);
       Msg msg = zmq.ZMQ.recv(s, 0);
       System.out.println("Response " + Arrays.toString(msg.data()));
    }
}

```

The code freezes in the line `Msg msg = zmq.ZMQ.recv(s, 0);`. I am using the calls described [here](https://github.com/libbitcoin/libbitcoin-server/blob/master/doc/prot-sphinx/api.rst) for the full node implemetation. Thanks in advance!

**Tags:** client, api, java, full-node, zeromq

> **Comments:**
> **username_1**: Double check, if you have started bitcoind with `-zmqpubhashtx=tcp://<ip>:<port>` and or `-zmqpubhashblock=tcp://<ip>:<port>`.  
> **username_1**: Also check https://github.com/bitcoin/bitcoin/blob/master/qa/rpc-tests/zmq_test.py   and keep in mind: zmq.ZMQ.recv does block your thread until bitcoind sends a block or tx.  

---

## 0 answers

