The documentation for connect
method says,
Connects to the socket at the given remote address and returns immediately. The connection will be made asynchronously in the background.
But, await
does not seem to be applicable as shown in their example of subscriber code.
subscriber.js
const zmq = require("zeromq")
async function run() {
const sock = new zmq.Subscriber
sock.connect("tcp://127.0.0.1:3000") //Happens async; can we await this?
sock.subscribe("kitty cats")
console.log("Subscriber connected to port 3000")
for await (const [topic, msg] of sock) {
console.log("received a message related to:", topic, "containing message:", msg)
}
}
run()
Also, what error(s) maybe raised by the connect()
method? I provided an 'obscene' port number such as, 8124000
, to connect. I was hoping for some error messages to be raised.