Code Monkey home page Code Monkey logo

zeromq.js's Introduction

ZeroMQ.js Next Generation

Latest version Greenkeeper monitoring Travis build status

⚠️ Version 6.0.0 (in beta) features a brand new API that solves many fundamental issues and is recommended for new projects. ⚠️

⚠️ For the current stable version see the 5.x branch ⚠️

ØMQ bindings for Node.js. The goals of this library are:

  • Semantically similar to the native ØMQ library, while sticking to JavaScript idioms.
  • Use modern JavaScript and Node.js features such as async/await and async iterators.
  • High performance.
  • Fully usable with TypeScript (3+).

Useful links

Table of contents

Installation

Install ZeroMQ.js with prebuilt binaries:

npm install [email protected]

Requirements for using prebuilt binaries:

  • Node.js 10.2+ or Electron 3+ (requires a N-API version 3+)

Prebuilt binaries

The following platforms have a prebuilt binary available:

  • Linux on x86-64 with libstdc++.so.6.0.21+ (glibc++ 3.4.21+), for example:
    • Debian 9+ (Stretch or later)
    • Ubuntu 16.04+ (Xenial or later)
    • CentOS 8+
  • Linux on x86-64 with musl, for example:
    • Alpine 3.3+
  • MacOS 10.9+ on x86-64
  • Windows on x86/x86-64

If a prebuilt binary is not available for your platform, installing will attempt to start a build from source.

Building from source

If a prebuilt binary is unavailable or if you want to pass certain options during build, you can build this package from source.

Make sure you have the following installed before attempting to build from source:

  • Node.js 10+ or Electron 3+
  • A working C++17 compiler toolchain with make
  • Python 3 with Node 12.13+ (or legacy Python 2.7)
  • CMake 2.8+
  • curl

To install from source:

npm install [email protected] --build-from-source

If you want to link against a shared ZeroMQ library, you can build skip downloading libzmq and link with the installed library instead as follows:

npm install [email protected] --zmq-shared

If you wish to use any DRAFT sockets then it is also necessary to compile the library from source:

npm install [email protected] --zmq-draft

Examples

Note: These examples assume the reader is familiar with ZeroMQ. If you are new to ZeroMQ, please start with the ZeroMQ documentation.

More examples can be found in the examples directory.

Push/Pull

This example demonstrates how a producer pushes information onto a socket and how a worker pulls information from the socket.

producer.js

Creates a producer to push information onto a socket.

const zmq = require("zeromq")

async function run() {
  const sock = new zmq.Push

  await sock.bind("tcp://127.0.0.1:3000")
  console.log("Producer bound to port 3000")

  while (true) {
    await sock.send("some work")
    await new Promise(resolve => { setTimeout(resolve, 500) })
  }
}

run()

worker.js

Creates a worker to pull information from the socket.

const zmq = require("zeromq")

async function run() {
  const sock = new zmq.Pull

  sock.connect("tcp://127.0.0.1:3000")
  console.log("Worker connected to port 3000")

  for await (const [msg] of sock) {
    console.log("work: %s", msg.toString())
  }
}

run()

Pub/Sub

This example demonstrates using zeromq in a classic Pub/Sub, Publisher/Subscriber, application.

publisher.js

Create the publisher which sends messages.

const zmq = require("zeromq")

async function run() {
  const sock = new zmq.Publisher

  await sock.bind("tcp://127.0.0.1:3000")
  console.log("Publisher bound to port 3000")

  while (true) {
    console.log("sending a multipart message envelope")
    await sock.send(["kitty cats", "meow!"])
    await new Promise(resolve => { setTimeout(resolve, 500) })
  }
}

run()

subscriber.js

Create a subscriber to connect to a publisher's port to receive messages.

const zmq = require("zeromq")

async function run() {
  const sock = new zmq.Subscriber

  sock.connect("tcp://127.0.0.1:3000")
  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()

Req/Rep

This example illustrates a request from a client and a reply from a server.

client.js

const zmq = require("zeromq")

async function run() {
  const sock = new zmq.Request

  sock.connect("tcp://127.0.0.1:3000")
  console.log("Producer bound to port 3000")

  await sock.send("4")
  const [result] = await sock.receive()

  console.log(result)
}

run()

server.js

const zmq = require("zeromq")

async function run() {
  const sock = new zmq.Reply

  await sock.bind("tcp://127.0.0.1:3000")

  for await (const [msg] of sock) {
    await sock.send(2 * parseInt(msg, 10))
  }
}

run()

TypeScript

This library provides typings for TypeScript version 3.0.x and later.

Requirements

  • For TypeScript version >= 3:
  • For TypeScript version < 3.6:
    • either set compilerOptions.target to esnext or later (e.g. es2018)
    • or add the following, or similar, libraries to compilerOptions.lib (and include their corresponding polyfills if needed): es2015, ESNext.AsyncIterable

Example Usage

import { Request } from "zeromq"
// or as namespace
import * as zmq from "zeromq"

const reqSock = new Request()
//...
const repSock = new zmq.Reply()

More examples

More advanced examples can be found in the examples directory of this repository.

Or you can browse the API reference documentation to see all socket types, methods & options as well as more detailed information about how to apply them.

Compatibility layer for version 4/5

The next generation version of the library features a compatibility layer for ZeroMQ.js versions 4 and 5. This is recommended for users upgrading from previous versions.

Example:

const zmq = require("zeromq/v5-compat")

const pub = zmq.socket("pub")
const sub = zmq.socket("sub")

pub.bind("tcp://*:3456", err => {
  if (err) throw err

  sub.connect("tcp://127.0.0.1:3456")

  pub.send("message")

  sub.on("message", msg => {
    // Handle received message...
  })
})

Contribution

If you are interested in making contributions to this project, please read the following sections.

Dependencies

In order to develop and test the library, you'll need the tools required to build from source (see above).

Additionally, having clang-format is strongly recommended.

Defining new options

Socket and context options can be set at runtime, even if they are not implemented by this library. By design, this requires no recompilation if the built version of ZeroMQ has support for them. This allows library users to test and use options that have been introduced in recent versions of ZeroMQ without having to modify this library. Of course we'd love to include support for new options in an idiomatic way.

Options can be set as follows:

const {Dealer} = require("zeromq")

/* This defines an accessor named 'sendHighWaterMark', which corresponds to
   the constant ZMQ_SNDHWM, which is defined as '23' in zmq.h. The option takes
   integers. The accessor name has been converted to idiomatic JavaScript.
   Of course, this particular option already exists in this library. */
class MyDealer extends Dealer {
  get sendHighWaterMark(): number {
    return this.getInt32Option(23)
  }

  set sendHighWaterMark(value: number) {
    this.setInt32Option(23, value)
  }
}

const sock = new MyDealer({sendHighWaterMark: 456})

When submitting pull requests for new socket/context options, please consider the following:

  • The option is documented in the TypeScript interface.
  • The option is only added to relevant socket types, and if the ZMQ_ constant has a prefix indicating which type it applies to, it is stripped from the name as it is exposed in JavaScript.
  • The name as exposed in this library is idiomatic for JavaScript, spelling out any abbreviations and using proper camelCase naming conventions.
  • The option is a value that can be set on a socket, and you don't think it should actually be a method.

Testing

The test suite can be run with:

npm install
npm run build
npm run test

The test suite will validate and fix the coding style, run all unit tests and verify the validity of the included TypeScript type definitions.

Some tests are not enabled by default:

  • API Compatibility tests from ZeroMQ 5.x have been disabled by default. You can include the tests with INCLUDE_COMPAT_TESTS=1 npm run test
  • Some transports are not reliable on some older versions of ZeroMQ, the relevant tests will be skipped for those versions automatically.

Publishing

To publish a new version, run:

npm version <new version>
git push && git push --tags

Wait for continuous integration to finish. Prebuilds will be generated for all supported platforms and attached to a Github release. Documentation is automatically generated and committed to gh-pages. Finally, a new NPM package version will be automatically released.

History

Version 6+ is a complete rewrite of previous versions of ZeroMQ.js in order to be more reliable, correct, and usable in modern JavaScript & TypeScript code as first outlined in this issue. Previous versions of ZeroMQ.js were based on zmq and a fork that included prebuilt binaries.

See detailed changes in the CHANGELOG.

zeromq.js's People

Contributors

aminya avatar lgeiger avatar tj avatar rgbkrk avatar rolftimmermans avatar justintulloss avatar kkoopa avatar alexeykupershtokh avatar f34rdotcom avatar interpretor avatar greenkeeper[bot] avatar mscdex avatar reqshark avatar minrk avatar jeremybarnes avatar bartel-c8 avatar n-riesco avatar captainsafia avatar valyouw avatar mlc avatar utvara avatar briansneddon avatar willingc avatar eximius avatar bluebery avatar soplwang avatar yoneal avatar wavded avatar aaudis avatar msealand avatar

Stargazers

Lee Byonghun avatar Benedikt Geisler avatar Wickramaranga Abeygunawardhana avatar Marcos Viana avatar Cleber Wilson avatar 이민용 avatar  avatar Dan avatar Konstantin Potyomkin avatar  avatar Tan Shi Yu avatar Sebastien Nobour avatar smari avatar  avatar Shaddy Mansour avatar Bence Kormos avatar Pluck avatar Rıdvan Demirhan avatar VTwo Group avatar  avatar Loïc avatar George Kontridze avatar Lucas Barbosa avatar Matthieu Borgognon avatar Cheng JIANG avatar Carl avatar Nikita Smith avatar wel2018 avatar  avatar Wasawat Somno avatar HT avatar Manuel avatar RV avatar Michael Newton avatar  avatar  avatar John Lin avatar Unknown Moon avatar Tomi Toivio avatar Sergey avatar Sebastian Rothe avatar ◤◢◤◢◤◢◤◢ avatar Mirdoriss avatar 刘伟 avatar Peter Szombati avatar Emanuele Innamorati avatar aofusa avatar Robin Kranich avatar  avatar  avatar Dawadam avatar  avatar Artur K. avatar Sebastian L. avatar Mitch O'Hair avatar Ali Sawari avatar Louis Nguyen avatar Rosso avatar seydx avatar Marcus Pöhls avatar  avatar Glenn 'devalias' Grant avatar  avatar antonia avatar Yuri Dias avatar Michał Kuklis avatar Emmanuel Salomon avatar Lawrence Lin avatar  avatar Yukai Huang avatar Dennki avatar 高昇 avatar Alaattin Gökmen  avatar Michael Morgan (Mícheál) avatar Mohanraj K Rangasamy avatar  avatar Ezra Lalonde avatar Christian Reichel avatar Baorong Li avatar Nick Dat Le avatar Jin Cheol avatar まっちゃとーにゅ avatar Ahmet Işıtan Narlı avatar Zheng Chen avatar devmor avatar Aliaksei avatar  avatar  avatar Ananta Bastola avatar Dima S. avatar Balamurugan Kandan avatar Daniel Azulay avatar Matthew Stevens avatar  avatar  avatar James Irwin avatar  avatar Apo avatar fengtwo avatar  avatar

Watchers

vince avatar Paul Ivanov avatar Constantin Rack avatar Andrew Odewahn avatar James Cloos avatar  avatar Yaşar İÇLİ avatar feeloc avatar  avatar Konstantin Vulsonov avatar 差点暴露 avatar Jack Parmer avatar Apratim Ankur avatar  avatar  avatar mosjin avatar TrasherDK avatar ccf19881030.github.io avatar  avatar luo jiyin avatar Joe Fox avatar zhukefeng avatar Mark avatar qxoffice2008 avatar  avatar johngai avatar  avatar  avatar  avatar  avatar seydx avatar  avatar leigo avatar Graham Robertson avatar David Sanders avatar Stanislav Bubnov avatar

zeromq.js's Issues

prebuild-install || (npm run build:libzmq && node-gyp rebuild) failed on centos 6.7

make: *** [Release/obj.target/zmq/binding.o] Error 1
make: Leaving directory `/home/node/node_modules/zeromq/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 2.6.32-573.7.1.el6.x86_64
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/node/node_modules/zeromq
gyp ERR! node -v v4.4.5
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
npm ERR! [email protected] install: `prebuild-install || (npm run build:libzmq && node-gyp rebuild)`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the zeromq package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     prebuild-install || (npm run build:libzmq && node-gyp rebuild)
npm ERR! You can get their info via:
npm ERR!     npm owner ls zeromq
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 2.6.32-573.7.1.el6.x86_64
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "i" "zeromq"
npm ERR! cwd /home/node
npm ERR! node -v v4.4.5
npm ERR! npm -v 1.4.3
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/node/npm-debug.log
npm ERR! not ok code 0

An in-range update of mocha is breaking the build 🚨

Version 3.4.0 of mocha just got published.

Branch Build failing 🚨
Dependency mocha
Current Version 3.3.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As mocha is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/appveyor/branch AppVeyor build succeeded Details,- ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v3.4.0

Mocha is now moving to a quicker release schedule: when non-breaking changes are merged, a release should happen that week.

This week's highlights:

  • allowUncaught added to commandline as --allow-uncaught (and bugfixed)
  • warning-related Node flags

🎉 Enhancements

🐛 Fixes

🔩 Other

Commits

The new version differs by 9 commits0.

  • 7554b31 Add Changelog for v3.4.0
  • 9f7f7ed Add --trace-warnings flag
  • 92561c8 Add --no-warnings flag
  • ceee976 lint test/integration/fixtures/simple-reporter.js
  • dcfc094 Revert "use semistandard directly"
  • 93392dd no special case for macOS running Karma locally
  • 4d1d91d --allow-uncaught cli option
  • fb1e083 fix allowUncaught in browser
  • 4ed3fc5 Add license report and scan status

false

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Unknown error message when using this lib

I'm switching from zmq to zeromq. As all the apis are compatible, the migration process is quite smooth. After running my app for couple of days, I might randomly see such a warning. I don't know, whether it is related to zeromq. Could you kindly have a quick look?

Assertion failed: Invalid argument (........\src\select.cpp:97)

Buffer.toString() returns a JS Object instead to String litrerals

I have written a small piece of code that sends request via IPC between two difference processes using REQ-RES pattern.

Here is process 1 that sends the request.

const zmq = require("zeromq");
const fs = require('fs');
const req = zmq.socket('req');
const sub = zmq.socket('sub');
var connected = 0;

process.on('SIGINT', function() {
  setImmediate(function() { clearInterval(test); }); 
  process.nextTick(function() {
    req.close();
    process.nextTick(function() {
      sub.close();
      process.nextTick(function() {
        console.log('GoodBye');
        process.exit();
      });
    });
  });
})

sendRequest = function() {
 if(!connected)
  return console.log('not connected')
 req.send(JSON.stringify( { msg : 'hi'} ));
}

onSuccessResponse = function(obj) {
  console.log('success'); 
}

onErrorResponse = function(obj) {
   console.log('error');
}

handleResponse = function() {
   if(obj.type == 'RESPONSE') {
      if(obj.result == 'SUCCESS') {
        onSuccessResponse(obj)
      } else if (obj.result == 'ERROR') {
        onErrorResponse(obj)
      }
  } 
}

req.on('message',function(rep) {

  console.log('response recieved: ' + rep);
  var obj = JSON.stringify(rep);
  process.nextTick(handleReqResponse,obj);

})
sub.connect('ipc://pub.ipc');
req.connect('ipc://server.ipc');

sub.subscribe('status')
sub.on('message',function(topic,msg) {
  console.log('subcriber recieved message ' + msg + ' for topic ' + topic);
 if(msg == 'READY' ) {
   connected = 1;
 } else if(msg == 'TERMINATED') {
   connected = 0;
 }  
 console.log('connected: ' + connected);
});

var test = setInterval(sendRequest,2500);

And now for the server, which accepts requests and responds

const zmq = require('zeromq');
const pub = zmq.socket('pub');
const server = zmq.socket('rep');

function onTerminate() {

   process.nextTick(function() {
    setImmediate(function(){ clearTimer(timer) });
    process.nextTick(function() { 
       pub.send(['status','TERMINATED']) 
       process.nextTick(function() { 
         server.close(); 
         console.log('bye\n') 
         process.nextTick(function() { 
           pub.close()
           process.nextTick(function() { 
             process.exit() 
           });
         });
       });
    });  
   });

}

function handle(payload,fn) {
   console.log('do some work');
   var obj = {result : 'SUCCESS', type : 'RESPONSE' };
   fn(obj);
}

server.on('message',function(req) {
 console.log('is buffer: ' + Buffer.isBuffer(req)); //prints: is buffer: true
 console.log(req.toString('utf8')); //prints [object Object]
 handle(req.toString(), function(response) { //would have thrown an exception here if i tries to convert to json
     server.send(response);
 }); 
});

pub.bind("ipc://pub.ipc",function(err) {
   if(err)
     console.log(err);
   else 
     console.log('listening on pub.ipc');
});

server.bind("ipc://server.ipc",function(err) {
   if(err)
     console.log(err);
   else 
     console.log('listening on server.ipc');
});

var timer = setInterval(function() {
  pub.send(['status','READY']);
},2000)

process.on('SIGINT',onTerminate);

Any help would be appreciated thanks.

p.s

I'm using node version 4.7.3, zeromq.js version 4.1.1

Release Steps

Now that we have prebuilds for all OSes that trigger on tags thanks to:

It's time to figure out how to do releases.

I just realized that when making a release we'll want to do:

npm version minor && git push && git push --tags

Followed by waiting for the prebuilds to come back for each OS, then finally running:

npm publish

electron app cannot find zeromq module

Electron version : 1.4.13

Description: zeromq works fine in node environment when I start electron app with "npm start"
But when I bundle the app using electron-packager it fails to find zeromq module

I have rebuilt zeromq as recommended in

https://github.com/zeromq/zeromq.js#rebuilding-for-electron

npm rebuild zeromq --runtime=electron --target=1.4.13

But when I bundle my electron app with below electron-packager command,

it complains that zeromq module couldn't be found

electron-packager . --overwrite --platform=darwin --arch=x64 --prune=true

Any suggestions on how I can include zeromq module into my electron
app successfully.

Appreciate it

socker('req').send is queued?

Hi,
I'm having some problem with understanding this nodejs binding and make use of it.

First, in C#, reqsock.send twice throws an exception, because it violates the pattern.

In zeromq.js, however. all reqsock.send seem to be queued. They will be executed as soon as there is a connection. Then all responses will come in in reqsocket.on('message', ...).

If there's no server, a lot of requests may queue whose response (at some time in the future) is not important anymore and may in fact cause wrong behaviour.

How is this intended to work? Is there any way to clear the queue?

Thanks

API documentation

I'm new to javascript but have used zeromq before with c and c++. How do I find the names of methods, arguments, options etc here? Where should I look?

I tried running some examples on windows but it failed to run. Interestingly, the same example runs in Linux. I tried asyncsrv.js from https://github.com/booksbyus/zguide/tree/master/examples/Node.js.

E:\Workspace\javascript\zmq>node asyncs.js
E:\Workspace\javascript\zmq\node_modules\zeromq\lib\index.js:720
this._zmq.close();
^

TypeError: Socket is closed
at TypeError (native)
at Socket.close (E:\gkashyap\Workspace\javascript\zmq\node_modules\zeromq\lib\index.js:720:13)
at Timeout._onTimeout (E:\gkashyap\Workspace\javascript\zmq\asyncs.js:26:12)
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5)
events.js:160
throw er; // Unhandled 'error' event
^

Error: write EPIPE
at exports._errnoException (util.js:1022:11)
at ChildProcess.target._send (internal/child_process.js:654:20)
at ChildProcess.target.send (internal/child_process.js:538:19)
at sendHelper (cluster.js:751:15)
at send (cluster.js:534:12)
at exitedAfterDisconnect (cluster.js:467:5)
at Worker.onmessage (cluster.js:454:7)
at ChildProcess. (cluster.js:765:8)
at emitTwo (events.js:111:20)
at ChildProcess.emit (events.js:191:7)

E:\gkashyap\Workspace\javascript\zmq>node asyncs.js
E:\gkashyap\Workspace\javascript\zmq\node_modules\zeromq\lib\index.js:720
this._zmq.close();
^

TypeError: Socket is closed
at TypeError (native)
at Socket.close (E:\gkashyap\Workspace\javascript\zmq\node_modules\zeromq\lib\index.js:720:13)
at Timeout._onTimeout (E:\gkashyap\Workspace\javascript\zmq\asyncs.js:26:12)
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5)
events.js:160
throw er; // Unhandled 'error' event
^

Error: write EPIPE
at exports._errnoException (util.js:1022:11)
at ChildProcess.target._send (internal/child_process.js:654:20)
at ChildProcess.target.send (internal/child_process.js:538:19)
at sendHelper (cluster.js:751:15)
at send (cluster.js:534:12)
at exitedAfterDisconnect (cluster.js:467:5)
at Worker.onmessage (cluster.js:454:7)
at ChildProcess. (cluster.js:765:8)
at emitTwo (events.js:111:20)
at ChildProcess.emit (events.js:191:7)

socket.pause() does not work at message level - is this by design?

As a 0mq learning exercise, I started implementing missing node.js examples in the guide. Ran into trouble here - http://zguide.zeromq.org/page:all#Prototyping-the-Local-and-Cloud-Flows: the queueing logic relies on ability to selectively poll sockets. The pause()/resume() pair looked like it would do the trick so I tried it and discovered that the implementation uses a JS-only mode flag that is checked after the binding signals readiness but before dispatching the entire batch of messages. However it is not checked inside the loop iterating over the batch:

var cutoff = 1;
socket.on( 'message', _ => --cutoff == 0 && socket.pause() );

will not actually pause until the entire batch of available messages is dispatched blithely running cutoff into negative!

Questions:

  1. Is this a design decision or an oversight -- the documentation is very sparse?
  2. Is there a preferred alternative to socket pausing that will provide an ability akin to a selective poll?
  3. If 1=oversight and 2=no, will you accept a patch that changes the granularity of socket.pause() to the level of an individual message?

What is FD_SETSIZE set to?

I'm having a boost of new clients using my Windows server and my previously compiled 0MQ (4.0.4) module hit a FD limit.

Do you have any idea what the current FD_SETSIZE for 4.2.0 (specifically the zeromq.js release) is ?

Builds aren't working on OS X.

In reality, I only need to do this per tagged release which I can do in automation for Windows and Linux in the ☁️ while doing the Mac builds on my local box.

Support for building zeromq with yarn instead of npm

I have a custom docker image of NodeJs 7.7.1 without NPM package manager instead, there is Yarn.
While installing zeromq in the container, it failed with the following error message -

Kindly note the docker environment does not have NPM in it, but only Yarn.

error /tmp/app/node_modules/zeromq: Command failed.
Exit code: 127
Command: sh
Arguments: -c prebuild-install || (npm run build:libzmq && node-gyp rebuild)
Directory: /tmp/app/node_modules/zeromq
Output:
prebuild-install info begin Prebuild-install version 2.1.2
prebuild-install info looking for local prebuild @ prebuilds/zeromq-v4.2.1-node-v51-linux-x64.tar.gz
prebuild-install info npm cache directory missing, creating it...
prebuild-install info looking for cached prebuild @ /root/.npm/_prebuilds/https-github.com-zeromq-zeromq.js-releases-download-v4.2.1-zeromq-v4.2.1-node-v51-linux-x64.tar.gz
prebuild-install http request GET https://github.com/zeromq/zeromq.js/releases/download/v4.2.1/zeromq-v4.2.1-node-v51-linux-x64.tar.gz
prebuild-install http 200 https://github.com/zeromq/zeromq.js/releases/download/v4.2.1/zeromq-v4.2.1-node-v51-linux-x64.tar.gz
prebuild-install info downloading to @ /root/.npm/_prebuilds/https-github.com-zeromq-zeromq.js-releases-download-v4.2.1-zeromq-v4.2.1-node-v51-linux-x64.tar.gz.34-018f5a3dd1c5c.tmp
prebuild-install info renaming to @ /root/.npm/_prebuilds/https-github.com-zeromq-zeromq.js-releases-download-v4.2.1-zeromq-v4.2.1-node-v51-linux-x64.tar.gz
prebuild-install info unpacking @ /root/.npm/_prebuilds/https-github.com-zeromq-zeromq.js-releases-download-v4.2.1-zeromq-v4.2.1-node-v51-linux-x64.tar.gz
prebuild-install info unpack resolved to /tmp/app/node_modules/zeromq/build/Release/zmq.node
prebuild-install WARN install Dynamic loading not supported
sh: npm: not found
The command '/bin/sh -c yarn' returned a non-zero code: 1

Name change to zeromq

TJ Holowaychuk was kind enough to give us the name zeromq on npm. Since we both have prebuilds and can do fallbacks/building from source cleanly across the three major operating systems, it's time for a name change that reflects our ability to provide ØMQ in general.

Let's figure out our next steps. (edited by @lgeiger)

  • Transfer ownership of this repository to the ØMQ project
  • Rename the repo to zeromq.js or node-zeromq
  • Update the package details in package.json and README
  • Activate Travis and AppVeyor
  • Check if the webhooks still work
  • Figure out what to do with the docs on gh-pages
  • Provide more detail in the intro of our README about how you can still build from source (for node, for Atom, and for electron) See #79
  • Choose a version number for release of zeromq (maybev3.0.0?)
  • Publish zeromq to npm
  • Deprecate the zmq-prebuilt npm package

Setting SNDHWM has no effect

Setting the SNDHWM currently has no effect to the public api.
The zmq sendv function returns true while the socket doesn't block, otherwise it returns false.
The index.js creates a BatchList and stores all outgoing message buffers as an OutBatch in the list. The BatchList wraps the sendv function, and the outgoing messages, that could not be sent due to the blocking socket, remain without any event or return value in the list.
Why there is another queue implemented in JS around the zmq sockets?
With this behavior I cannot say if a message has been delivered or not. Or am I missing here something, and I can tell in some way if the message has been delivered?

The point is that I would need to know which messages could be delivered after a period of time, so closing the socket doesn't destroy the messages (and therefore they will be lost forever).

What's the difference from npm's zmq and zeromq?

I'm currently trying to run this example from the ZeroMQ guide: http://zguide.zeromq.org/js:taskvent
however, since I got this problem JustinTulloss/zeromq.node#586 when doing npm install zmq I discovered this other zeromq nodejs binding, which seems like the official one. However, if it's official, why the guide examples require zmq and not zeromq?

I tried to modify require('zmq') to require('zeromq') but I got this error:

require('tty').setRawMode(true);
               ^

TypeError: require(...).setRawMode is not a function

Remove npm prepublish script

Since we're deploying prebuilds via travis is this script needed anymore?

"prepublish": "in-publish && node build.js || echo 'Not in npm prepublish.'",

Shrink node_module size

After installing zmq-prebuilt, the node_module directory will be 36MB on my machine. This will be a bit too large for a slow connection for first time downloading. There are a lot of dependencies that might only related for the build process.

I tried to shrink the package to less than 1.5MB by keeping only bindings and nan and zmq-prebuilt/build (sure including all readme and license files). It works just fine. As I'm not a ZMQ heavy user, I don't know, whether my change will break anything.

If it is not, I think we can remove irrelevant stuffs in postinstall section.

Work both with node and electron

Hi,

I use zeromq in a an electron app, so I rebuilt zeromq according to the command given in the docs:
npm rebuild zeromq --runtime=electron --target=1.6.1

But, well, now it's broken for node. When running jest, it complains that Module version mismatch. Expected 48, got 53., 53 being the Electron version, while 48 corresponds to my Node version.

This is annoying for setting up a correct development environment. I do not seem to be the first to meet this issue, but I found no solution.

To my mind, the module version should only be checked against node version, not eletron version, so that if I use the same version of node as electron I should not see this issue. To sum it up:

Today I got this:
I use Electron version : 53 / I use Node version 48 ===> mismatch error
But I should have this instead:
I use Electron version 53 ; Electron uses Node version 48 / I use Node version 48 ===> no mismatch error

Is that doable ?

cross compilation issue

Hi,
I'm trying to cross compile for linux ArmV7(32 bit) on a linux 64 bit machine, but i'm getting this error. Any help is appreciated.

> node scripts/preinstall.js

Building libzmq for linux
configure: loading site script /usr/local/slp-redwolf-x86_64/site-config-cortexa8hf-vfp-neon-oe-linux-gnueabi
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking how to create a ustar tar archive... gnutar
checking whether make supports nested variables... yes
checking for gcc... arm-oe-linux-gnueabi-gcc  -march=armv7-a -marm  -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/usr/local/slp-redwolf-x86_64/sysroots/cortexa8hf-vfp-neon-oe-linux-gnueabi
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... configure: error: in `/home/test/linux-arm/zmqtest/node_modules/zeromq/zmq/zeromq-4.1.6':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
child process exited with code 1
make: Entering directory `/home/test/linux-arm/zmqtest/node_modules/zeromq/build'
  CXX(target) Release/obj.target/zmq/binding.o
  SOLINK_MODULE(target) Release/obj.target/zmq.node
arm-oe-linux-gnueabi-g++: error: ./Release/../../zmq/lib/libzmq.a: No such file or directory
make: *** [Release/obj.target/zmq.node] Error 1
make: Leaving directory `/home/test/linux-arm/zmqtest/node_modules/zeromq/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 3.13.0-24-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/test/linux-arm/zmqtest/node_modules/zeromq
gyp ERR! node -v v6.9.2
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok 

Deploy prebuilds with travis and appveyor

We could use travis to automatically deploy the prebuilds to github if a new tag is pushed. This would make shipping new versions a lot easier.

If this is something you like to see, I'm happy to fiddle around with travis and make a PR.


Edit:

  • travis
  • appveyor

Remove ZMQ version related code

I noticed quite a bit of code for handling old ZMQ versions. Since we bundle ZMQ 4.1.5 we could remove it.
Should we do this?

Weird and not reproducible error "Resource temporarily unavailable (src/signaler.cpp:282)"

I am building a node.js port of zyre (https://github.com/interpretor/zyre.js). As specified in https://rfc.zeromq.org/spec:36/ZRE/, I am using router and dealer sockets for communication.
My simple (and not final) unit test of the zyre module is throwing not reproducible errors only in Travis:

  Zyre
    ✓ should create a new instance of Zyre
    ✓ should inform about evasive peers (5104ms)
    ✓ should inform about expired peers (30103ms)
Resource temporarily unavailable (src/signaler.cpp:282)
Aborted (core dumped)
npm ERR! Test failed.  See above for more details.

On my Mac and my Ubuntu machine, I don't have those errors, and they don't occur every time in Travis. They even don't occur on the same unit test every time, this varies.
In the example above, the last test that passed creates two zmq router and two zmq dealer socket, and then closes those sockets after some time.
Then the next test should create another two zmq router and dealer sockets, and that is the point where it seems to crash.

Can someone give me a hint, what could be a possible reason for this behavior? This could be an issue of the zeromq.js binding, since the error happens somewhere in the libzmq binary.

Upgrade to libzmq 4.2 on Linux

The prebuilt binaries fail on Travis CI with the following error when trying to require them:

/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /home/travis/build/nteract/zmq-prebuilt-testing/node_modules/zeromq/build/Release/zmq.node)

I guess this is cause by the upgrade to libzmq 4.2.0

Stack overflow tells us:

So, this problem occurs when a library that has been built with a newer compiler is linked with an older version of C++ library - or sometimes when a newer headerfile is used to compile something that then links to an older C++ library.
It is also possible come up with a similar problem when moving binary files from one system to another, if the shared libraries installed on the "new system" are older than the ones on which the code was built.
There are typically three plausible solutions: 1. Recompile the offending library with an older compiler. 2. Install a newever version of the C++ library. 3. Rebuild the C++ library from sources (with a new enough compiler).

We built the binaries with gcc 4.9 so this could be the problem. The strange thing is that it worked for v3.0.0.

Should we try to build with gcc 4.8 or earlier? I have no idea if this would fix it.

An in-range update of nan is breaking the build 🚨

Version 2.6.1 of nan just got published.

Branch Build failing 🚨
Dependency nan
Current Version 2.6.0
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

As nan is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this 💪


Status Details
  • continuous-integration/travis-ci/push The Travis CI build passed Details

  • continuous-integration/appveyor/branch AppVeyor build failed Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Fix the monitor (or test)

Right now the monitor test is timing out:

  socket.monitor
    ◦ should be able to monitor the socket:

Which makes our tests fail. Would love help @minrk.

install behind proxy

there is a timeout if it installed behind a proxy, because the download.js do not use the npm proxy settings.

TypeError: zmq.zmqVersion is not a function

Hi,

When I try to import ZeroMQ (var zmq = require('zeromq');) in a new React application created with create-react-app, I get this error: TypeError: zmq.zmqVersion is not a function.

Has someone succeeded in using ZeroMQ with React ? I only need a subscriber to monitor what is sent from a ZeroMQ application written in Python.

Is it possible to use zeromq node.js binding with Angular/Cordova app?

I have tried importing node.js binding from npm. Obviously, the 'require' keyword does not work in the angular/cordova app. Neither does the 'import' keyword, apparently because the zmq.node binary is not really built for an angular/cordova app. I tried to browserify and that failed too. So my question here is if it is possible at all to use a node.js binding inside an angular/cordova mobile app to create a zmq client communicating with a zmq server running in a different device?

"npm install" requires access to github.com

Dear developers,

When I use npm install on Linux, the script attempts to fetch something from github.com. However in a corporation this might not be always possible. Could you revise the installation script, so that use npm install to do everything?

> [email protected] build:libzmq /path/to/proj/node_modules/zeromq
> node scripts/preinstall.js

events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: getaddrinfo ENOTFOUND github.com github.com:443
    at errnoException (dns.js:28:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:79:26)

npm ERR! Linux 2.6.32-642.6.2.el6.x86_64
npm ERR! argv "/path/to/node" "/path/to/npm" "run" "build:libzmq"

4198 error node v6.2.0
4199 error npm  v3.8.9
4200 error code ELIFECYCLE
4201 error [email protected] install: `prebuild-install || (npm run build:libzmq && node-gyp rebuild)`
4201 error Exit status 1
4202 error Failed at the [email protected] install script 'prebuild-install || (npm run build:libzmq && node-gyp rebuild)'.
4202 error Make sure you have the latest version of node.js and npm installed.
4202 error If you do, this is most likely a problem with the zeromq package,
4202 error not with npm itself.
4202 error Tell the author that this fails on your system:
4202 error     prebuild-install || (npm run build:libzmq && node-gyp rebuild)
4202 error You can get information on how to open an issue for this project with:
4202 error     npm bugs zeromq
4202 error Or if that isn't available, you can get their info via:
4202 error     npm owner ls zeromq
4202 error There is likely additional logging output above.
4203 verbose exit [ 1, true ]

ZMQ_ROUTER_HANDOVER not available

The ZMQ_ROUTER_HANDOVER option is not available in the current version, it was only added in the Windows header file.
This is already version > 4.1, so it should be available.

libzmq.5.dylib linking issue with electron-packager

I'm fairly new to everything Node. Trying to build an Electron app on OSX 10.12. I've used homebrew to install zeromq. My app requires zerorpc and zmq. I set these env vars

npm_config_target="1.6.2" 
npm_config_runtime="electron"
npm_config_disturl="https://atom.io/download/electron"
npm_config_build_from_source="true"

Then package.

./node_modules/.bin/electron-packager .  --overwrite

It works fine on the local dev machine but when copied to another machine it fails because the dylib for zeromq is not found.

zmq-dylib-fail

I'm not really clear on what I need to do to get that file inside the packaged app. Perhaps I'm doing something wrong or missed a step.

Download assets using node instead of wget

To cut down on dependencies for end users (especially for new devs in nteract/nteract), rely on the platform they're guaranteed to be using: node.js

The other alternative is to do fallback:

  • curl
  • wget
  • custom node way

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.