<p>If I understand this correctly, you're trying to communicate with Bitcoin Core through ZeroMQ directly from the browser.
<strong>This is not possible.</strong></p>

<p>The reason why JSMQ only supports Websockets (ws://) is that browsers don't allow you to use raw TCP sockets. The only protocols you can access from within the browser are HTTP(S), Websockets, and WebRTC (which is still not supported everywhere).</p>

<p>In other words: the browser won't let you communicate directly through ZeroMQ.</p>

<p>If you don't want to rely on an external API, then you can always write your own and run it on the same server/computer where you are currently running Bitcoin Core.
This software should receive updates from the Bitcoin node through ZeroMQ, and send them to the browser via websockets.</p>

<p>As long as it supports websockets or HTTP(S) you'll be able to connect to it from within your browser.</p>

CC BY-SA 4.0
2018-12-01T01:40:10.150Z
2018-12-01T01:40:10.150Z
Reasv
<p>I am trying to develop an online application primarily in JavaScript. As I am aware, the only way to receive notifications for unconfirmed/mempool transactions as they appear on the network is to utilize the <code>-zmqpubrawtx</code> or <code>-zmqpubhashtx</code> commands in the startup of Bitcoin-Core. I have setup one of these values to be the example <code>-zmqpubhashtx=tcp://127.0.0.1:28332</code></p>

<p>However, I am having a difficult time implementing this in any browser based JavaScript. The only library that is not based solely on Node.js is <a href="https://github.com/zeromq/JSMQ" rel="noreferrer">JSMQ</a> which does not appear to support <code>tcp://</code> as the socket type (apparently relies on JavaScripts WebSocket which only lets you use <code>ws://</code> or <code>wss://</code>). I am trying to avoid online API usage such as blockchain.info, etc.</p>

<p>My question:
Are there any other methods of receiving realtime unconfirmed transactions notifications (that don't belong to a specific wallet) and that doesn't rely on an external/online API? If there is no alternative, are there any known/reputable libraries available for ZeroMQ for JavaScript</p>

<bitcoin-core><zeromq><websockets>
ZeroMQ Notifications in Browser JavaScript
OmegaLulz
# ZeroMQ Notifications in Browser JavaScript

(Asked by: username_0 on 2018-11-06)

I am trying to develop an online application primarily in JavaScript. As I am aware, the only way to receive notifications for unconfirmed/mempool transactions as they appear on the network is to utilize the `-zmqpubrawtx` or `-zmqpubhashtx` commands in the startup of Bitcoin-Core. I have setup one of these values to be the example `-zmqpubhashtx=tcp://127.0.0.1:28332`

However, I am having a difficult time implementing this in any browser based JavaScript. The only library that is not based solely on Node.js is [JSMQ](https://github.com/zeromq/JSMQ) which does not appear to support `tcp://` as the socket type (apparently relies on JavaScripts WebSocket which only lets you use `ws://` or `wss://`). I am trying to avoid online API usage such as blockchain.info, etc.

My question:
Are there any other methods of receiving realtime unconfirmed transactions notifications (that don't belong to a specific wallet) and that doesn't rely on an external/online API? If there is no alternative, are there any known/reputable libraries available for ZeroMQ for JavaScript

**Tags:** bitcoin-core, zeromq, websockets


---

## 1 answers

### Answer by username_1 on 2018-12-01. Score: 2

If I understand this correctly, you're trying to communicate with Bitcoin Core through ZeroMQ directly from the browser.
**This is not possible.**

The reason why JSMQ only supports Websockets (ws://) is that browsers don't allow you to use raw TCP sockets. The only protocols you can access from within the browser are HTTP(S), Websockets, and WebRTC (which is still not supported everywhere).

In other words: the browser won't let you communicate directly through ZeroMQ.

If you don't want to rely on an external API, then you can always write your own and run it on the same server/computer where you are currently running Bitcoin Core.
This software should receive updates from the Bitcoin node through ZeroMQ, and send them to the browser via websockets.

As long as it supports websockets or HTTP(S) you'll be able to connect to it from within your browser.


---

