Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending buffer object with bytes over >= 128 causes data to be corrupted. #335

Closed
frank-palmasani opened this issue Aug 2, 2019 · 1 comment

Comments

@frank-palmasani
Copy link

Seems it has to do with the conversion to a string and then utf-8 encoding.

A buffer, for example with the following data:

<48 128 1>

is changed to something like

<48 262 191>

The code in question is in node_modules/zeromq/lib/index.js:

OutBatch.prototype.append = function (buf, flags, cb) {

  // commented this out. causes errors in protobuf data. need to message 'npm zeromq' guys about this.
  // if (!Buffer.isBuffer(buf)) {
  //   buf = Buffer.from(String(buf), 'utf8');
  // }

  this.content.push(buf, flags);

  if (cb) {
    this.cbs.push(cb);
  }

  if ((flags & zmq.ZMQ_SNDMORE) === 0) {
    this.isClosed = true;
  }
};
@rolftimmermans
Copy link
Member

The latest 6.0 beta release should support sending buffers as well as strings, no matter in which encoding. It would be great if you could try it out! The new version has a new API that addresses some fundamental issues with the previous API, but it does include a compatibility layer that should make upgrading easier. See #189 for the reasoning behind the new API. If you run into any problems feel free to report it here or in a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants