Closed
Description
Hi,
I am trying to figure out how to send an Uint8Array over a PUB/SUB pattern.
Currently, the array I publish differs from the one I receive. Could this be caused
by the fact that the array is not encoded into binary and instead text?
Here is a minimal working example of this issue :
const zmq = require('zeromq')
const { expect } = require('chai')
const ZMQ_ADDR = 'tcp://127.0.0.1:5000'
let sndArr = new Uint8Array([21,31]);
let pub = zmq.socket('pub');
pub = zmq.socket('pub')
pub.bindSync(ZMQ_ADDR)
let sub = zmq.socket('sub');
sub.connect(ZMQ_ADDR);
sub.subscribe('topic');
sub.on('message', function(topic, message) {
let recvArr = new Uint8Array(message)
expect(recvArr.toString()).to.equal(sndArr.toString())
});
pub.send(['topic', sndArr])
Example output :
...
AssertionError: expected [ 50, 49, 44, 51, 49 ] to equal [ 21, 31 ]
...
Metadata
Metadata
Assignees
Labels
No labels