Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Fix multipart messages for xpub/xsub #593

Merged
merged 2 commits into from
May 25, 2017

Conversation

BryceCicada
Copy link
Contributor

The following code snippet demonstrates that proxy is only forwarding the first part of a multipart message:

let zmq = require('zmq');
let subs = zmq.socket('xpub');
let pubs = zmq.socket('xsub');

subs.bindSync('tcp://127.0.0.1:3000');
pubs.bindSync('tcp://127.0.0.1:3001');
console.log('Proxy bound to to ports 3000 and 3001');
zmq.proxy(subs, pubs);


let subscriber = zmq.socket('sub');
subscriber.connect('tcp://127.0.0.1:3000');
subscriber.subscribe('');
console.log('Subscriber connected to port 3000');
subscriber.on('message', function (part1, part2) {
    console.log(part1.toString(), ':', part2 && part2.toString());
});


let publisher = zmq.socket('pub');
publisher.connect('tcp://127.0.0.1:3001');
console.log('Publisher connected to port 3001');
setInterval(() => {
    publisher.send(['foo', 'bar']);
}, 500);

wherein the publisher sends two parts, but the subscriber only receives the first part.

This change fixes the proxy so that it sends all parts to the subscriber.

Related issue #412

Copy link
Contributor

@reqshark reqshark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it looks good, can we do:

[].slice.call(arguments)

or do we have to use the Array.prototype syntax?

@BryceCicada
Copy link
Contributor Author

@reqshark Syntax changed as requested.

@reqshark
Copy link
Contributor

thanks @BryceCicada!

@ronkorving
Copy link
Collaborator

LGTM, thanks!
@reqshark welcome back, it's been a while ;)

@ronkorving ronkorving merged commit 42c5b80 into JustinTulloss:master May 25, 2017
@BryceCicada BryceCicada deleted the multipart-xpubsub branch May 25, 2017 21:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants