<p>It is not specified what to subscribe.</p>

<pre><code>socket.connect("tcp://127.0.0.1:28332")

socket.subscribe("hashtx");
# if you need raw data or block data, to add-&gt;
socket.subscribe("hashblock");
socket.subscribe("rawblock");
socket.subscribe("rawtx");
</code></pre>

<p>see.
<a href="https://github.com/bitcoin/bitcoin/blob/master/contrib/zmq/zmq_sub.py" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/blob/master/contrib/zmq/zmq_sub.py</a></p>

CC BY-SA 3.0
2017-10-03T07:31:13.023Z
2017-10-03T07:31:13.023Z
hnak
<p>I'm trying to connect to Bitcoin's ZeroMQ queue, having no success and don't even know where my problem is. Here is what I did so far on my Ubuntu 14.04:</p>

<ol>
<li>Installed Bitcoin via <code>sudo apt-get install bitcoin-qt</code></li>
<li>installed ZeroMQ via <code>wget http://download.zeromq.org/zeromq-4.1.2.tar.gz &amp;&amp; cd libzmq/ &amp;&amp; ./autogen.sh &amp;&amp; ./configure &amp;&amp; make -j 4 &amp;&amp; make check &amp;&amp; make install</code></li>
<li>In my Scala application I use <code>jeromq</code>: <code>libraryDependencies += "org.zeromq" % "jeromq" % "0.3.5"</code></li>
<li>In Bitcoin's <code>bitcoin.conf</code> I add the following line: <code>zmqpubhashtx=tcp://127.0.0.1:28332</code> (i'm only interested in incoming tx id's)  </li>
</ol>

<p>After doing all that I launch Bitcoin, then I launch my Scala app with the following code:  </p>

<pre><code>import org.zeromq.ZMQ
val context = ZMQ.context(1)
val socket = context.socket(ZMQ.SUB) // Since server side is PUB
socket.connect("tcp://127.0.0.1:28332")

while (true) {
  logger info socket.recv.length.toString
}
</code></pre>

<p>And I receive no messages. Thing is I don't even know what the problem is or how to test it. Does <code>apt-get</code> version of Bitcoin even has ZeroMQ support? On <code>jeromq</code> github it is stated that it's <code>Based on libzmq 3.2.5</code> while Bitcoin requires <code>ZeroMQ API version 4.x or newer</code>, could that be a reason? Or perhaps it's something else entirely?</p>

<java><zeromq>
Bitcoin ZeroMQ and Scala application
src091
# Bitcoin ZeroMQ and Scala application

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

I'm trying to connect to Bitcoin's ZeroMQ queue, having no success and don't even know where my problem is. Here is what I did so far on my Ubuntu 14.04:

1. Installed Bitcoin via `sudo apt-get install bitcoin-qt`
2. installed ZeroMQ via `wget http://download.zeromq.org/zeromq-4.1.2.tar.gz && cd libzmq/ && ./autogen.sh && ./configure && make -j 4 && make check && make install`
3. In my Scala application I use `jeromq`: `libraryDependencies += "org.zeromq" % "jeromq" % "0.3.5"`
4. In Bitcoin's `bitcoin.conf` I add the following line: `zmqpubhashtx=tcp://127.0.0.1:28332` (i'm only interested in incoming tx id's)

After doing all that I launch Bitcoin, then I launch my Scala app with the following code:

```
import org.zeromq.ZMQ
val context = ZMQ.context(1)
val socket = context.socket(ZMQ.SUB) // Since server side is PUB
socket.connect("tcp://127.0.0.1:28332")

while (true) {
  logger info socket.recv.length.toString
}

```

And I receive no messages. Thing is I don't even know what the problem is or how to test it. Does `apt-get` version of Bitcoin even has ZeroMQ support? On `jeromq` github it is stated that it's `Based on libzmq 3.2.5` while Bitcoin requires `ZeroMQ API version 4.x or newer`, could that be a reason? Or perhaps it's something else entirely?

**Tags:** java, zeromq


---

## 1 answers

### Answer by username_1 on 2017-10-03. Score: 2

It is not specified what to subscribe.

```
socket.connect("tcp://127.0.0.1:28332")

socket.subscribe("hashtx");
# if you need raw data or block data, to add->
socket.subscribe("hashblock");
socket.subscribe("rawblock");
socket.subscribe("rawtx");

```

see.
<https://github.com/bitcoin/bitcoin/blob/master/contrib/zmq/zmq_sub.py>


---

