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");
       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 for the full node implemetation. Thanks in advance!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.