Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@aminya/zeromq

zeromq38MIT5.2.16

ZeroMQ for node.js

zeromq, zmq, 0mq, ømq, libzmq, native, binding, addon

readme

zeromq.js

codecov Greenkeeper badge Build Status Build status Build Status Build status

Users | From Source | Contributors and Development | Maintainers

zeromq: Your ready to use, prebuilt ØMQ bindings for Node.js.

ØMQ provides handy functionality when working with sockets. Yet, installing dependencies on your operating system or building ØMQ from source can lead to developer frustration.

zeromq simplifies creating communications for a Node.js application by providing well-tested, ready to use ØMQ bindings. zeromq supports all major operating systems, including:

  • OS X/Darwin (x64)
  • Linux (x64, ARMv7 and ARMv8)
  • Windows (x64 and x86)

Use zeromq and take advantage of the elegant simplicity of binaries.

Installation - Users

We rely on prebuild.

Install zeromq with the following:

npm install zeromq@5

windows users: do not forget to set msvs_version according to your visual studio version 2013,2015,2017 npm config set msvs_version 2015 Now, prepare to be amazed by the wonders of binaries.

To use your system's libzmq (if it has been installed and development headers are available):

npm install zeromq@5 --zmq-external

Rebuilding for Electron

If you want to use zeromq inside your Electron application it needs to be rebuild against Electron headers. We ship prebuilt binaries for Electron so you won't need to build zeromq from source.

You can rebuild zeromq manually by running:

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

Where target is your desired Electron version. This will download the correct binary for usage in Electron.

For packaging your Electron application we recommend using electron-builder which handles rebuilding automatically. Enable the npmSkipBuildFromSource option to make use of the prebuilt binaries. For a real world example take a look at nteract.

Installation - From Source

If you are working on a Linux 32-bit system or want to install a development version, you have to build zeromq from source.

Prerequisites

Linux

  • python (v2.7 recommended, v3.x.x is not supported)
  • make
  • A proper C/C++ compiler toolchain, like GCC

Use your distribution's package manager to install.

macOS

  • python (v2.7 recommended, v3.x.x is not supported): already installed on Mac OS X
  • Xcode Command Line Tools: Can be installed with xcode-select --install

Windows

  • Option 1: Install all the required tools and configurations using Microsoft's windows-build-tools by running npm install -g windows-build-tools from an elevated PowerShell (run as Administrator).
  • Option 2: Install dependencies and configuration manually

    1. Visual C++ Build Environment:
      • Option 1: Install Visual C++ Build Tools using the Default Install option.
      • Option 2: Install Visual Studio 2015 (or modify an existing installation) and select Common Tools for Visual C++ during setup.

    :bulb: [Windows Vista / 7 only] requires .NET Framework 4.5.1

    1. Install Python 2.7 or Miniconda 2.7 (v3.x.x is not supported), and run npm config set python python2.7
    2. Launch cmd, and set msvs_version according to your visual studio version 2013,2015,2017 npm config set msvs_version 2015

Installation

Now you can install zeromq with the following:

npm install zeromq@5

Installation - Contributors and Development

To set up zeromq for development, fork this repository and clone your fork to your system.

Make sure you have the required dependencies for building zeromq from source installed.

Install a development version of zeromq with the following:

npm install

Testing

Run the test suite using:

npm test

Running an example application

Several example applications are found in the examples directory. Use node to run an example. To run the 'subber' application, enter the following:

node examples/subber.js

Examples using zeromq

Push/Pull

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

producer.js

// producer.js
var zmq = require('zeromq')
  , sock = zmq.socket('push');

sock.bindSync('tcp://127.0.0.1:3000');
console.log('Producer bound to port 3000');

setInterval(function(){
  console.log('sending work');
  sock.send('some work');
}, 500);

worker.js

// worker.js
var zmq = require('zeromq')
  , sock = zmq.socket('pull');

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

sock.on('message', function(msg){
  console.log('work: %s', msg.toString());
});

Pub/Sub

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

Publisher: pubber.js

// pubber.js
var zmq = require('zeromq')
  , sock = zmq.socket('pub');

sock.bindSync('tcp://127.0.0.1:3000');
console.log('Publisher bound to port 3000');

setInterval(function(){
  console.log('sending a multipart message envelope');
  sock.send(['kitty cats', 'meow!']);
}, 500);

Subscriber: subber.js

// subber.js
var zmq = require('zeromq')
  , sock = zmq.socket('sub');

sock.connect('tcp://127.0.0.1:3000');
sock.subscribe('kitty cats');
console.log('Subscriber connected to port 3000');

sock.on('message', function(topic, message) {
  console.log('received a message related to:', topic, 'containing message:', message);
});

For maintainers: Creating a release

When making a release, do the following:

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

Then, wait for the prebuilds to get uploaded for each OS. After the prebuilds are uploaded, run the following to publish the release:

npm publish

Background

This codebase largely came from the npm module zmq and was, at one point, named nteract/zmq-prebuilt. It started as a community run fork of zmq that fixed up the build process and automated prebuilt binaries. In the process of setting up a way to do statically compiled binaries of zeromq for node, zmq-static was created. Eventually zmq-prebuilt was able to do the job of zmq-static and it was deprecated. Once zmq-prebuilt was shipping for a while, allowed building from source, and suggesting people use it for electron + node.js, the repository moved to the zeromq org and it became official.

changelog

2.15.3 / 2016-6-3

  • 2.15.0 introduced a bug where request sockets could no longer batch up requests. This release should fix that [ronkorving, jaleigh]

2.15.2 / 2016-5-22

  • 2.15.0 introduced a bug where some messages would not be received. This release should fix that [ronkorving]

2.15.1 / 2016-5-8

  • Node.js 6 compatibility (NAN 2.3) [kkoopa]

2.15.0 / 2016-4-27

  • Dropped support for Node 0.8 [reqshark]
  • Added unref/ref APIs to detach/attach sockets from/to the event loop [Joongi Kim]
  • Improved message throughput 3-fold on ZMQ 4 [ronkorving]
  • When bind or unbind failed, you could never try again (fixed) [ronkorving]
  • Various travis configuration improvements [reqshark]
  • Bumped NAN to 2.2.x [JanStevens]

2.14.0 / 2015-11-20

  • A socket.read() method was added to retrieve messages while paused [sshutovskyi]
  • socket.send() now takes a callback as 3rd argument which is called once the message is sent [ronkorving]
  • Now tested on Node.js 0.8, 0.10, 0.12, 4 and 5 [ronkorving]

2.13.0 / 2015-08-26

  • io.js 3.x compatible [kkoopa]
  • corrections to type casting operations [kkoopa]
  • "make clean" now also removes node_modules [reqshark]

2.12.0 / 2015-07-10

  • Massive improvements to monitoring code, with new documentation and tests [ValYouW]
  • Improved documentation [reqshark]
  • Updated bindings from ~1.1.1 to ~1.2.1 [reqshark]
  • Test suite improvements [reqshark]
  • Updated the Windows bundle to ZeroMQ 4.0.4 [kkoopa]
  • License attribute added to package.json [pdehaan]

2.11.1 / 2015-05-21

  • io.js 2.x compatible [transcranial]
  • replaced asserts with proper exceptions [reqshark]

2.11.0 / 2015-03-31

  • Added pause() and resume() APIs on sockets to allow backpressure [philip1986]
  • Elegant handling of EINTR return codes [hurricaneLTG]
  • Small performance improvements in send() and internal flush methods [ronkorving]
  • Updated test suite to cover io.js and Node 0.12 (removed 0.11) [ronkorving]
  • Added "make perf" for easy benchmarking [ronkorving]

2.10.0 / 2015-01-22

  • Added ZMQ_STREAM socket type [reqshark]
  • Update NAN to io.js compatible 1.5.0 [kkoopa]
  • Hitting open file descriptor limit now throws an error during zmq.socket() [briansorahan]
  • More reliable benchmarking [maxired]

2.9.0 / 2015-01-05

  • More unit tests [bluebery and reqshark]
  • More reliable testing [f34rdotcom and kkoopa]
  • Improved ReadMe [dminkovsky and skibz]
  • Support for zmq_proxy sockets [reqshark]
  • Removed "docs" and related deps in favor of ReadMe [reqshark]

2.8.0 / 2014-08-27

  • Fixed: monitor API would keep CPU busy at 100% [f34rdotcom]
  • Fixed: an exception during flush could render a socket unusable [ronkorving]
  • Fixed: Travis changed behavior and broke our tests [ronkorving]
  • Code cleanup [kkoopa and ronkorving]
  • Removed legacy nextTick event emission during flush [utvara and ronkorving]
  • Context API added: setMaxThreads, getMaxThreads, setMaxSockets, getMaxSockets [yoneal]
  • Changed unit test suite to Mocha [skeggse and yoneal]
  • NAN updated to ~1.3.0 [kkoopa]

2.7.0 / 2014-04-24

  • Fixed memory leak when closing socket [rasky]
  • Fixed high water mark [soplwang, kkoopa]
  • Added socket opts for zeromq 4.x security mechanisms [msealand]
  • Use MakeCallback [kkoopa]
  • Remove useless setImmediate [kkoopa]
  • Use zmq_msg_send for ZMQ >= 4.0 [kkoopa]
  • Expose the Socket class as zmq.Socket [tcr]

2.6.0 / 2014-01-23

  • Monitor support [f34rdotcom, dr-fozzy]
  • Unbind support [kkoopa]
  • Node 0.11.9 compatibility [kkoopa]
  • Support for ZMQ 4 [atrniv]
  • Fixed memory leak [utvara]
  • OSX Homebrew support [jwalton]
  • Fix unit tests [ryanlelek]

2.5.1 / 2013-08-28

  • Regression fix for IPC socket bind failure [christopherobin]

2.5.0 / 2013-08-20

  • Added testing against Node.js v0.11 [AlexeyKupershtokh]
  • Add support for Joyent SmartMachines [JonGretar]
  • Use pkg-config on OS X too [blalor]
  • Patch for Node 0.11.3 [kkoopa]
  • Fix for bind / connect / send problem [kkoopa]
  • Fixed multiple bugs in perf tests and changed them to push/pull [ronkorving]
  • Add definitions for building on openbsd & freebsd [Minjung]

2.4.0 / 2013-04-09

  • added: Windows support [mscdex]
  • added: support for all options ever [AlexeyKupershtokh]
  • fixed: prevent zeromq sockets from being destroyed by GC [AlexeyKupershtokh]

2.3.0 / 2013-03-15

  • added: xpub/xsub socket types [xla]
  • added: support for zmq_disconnect [matehat]
  • added: LAST_ENDPOINT socket option [ronkorving]
  • added: local/remote_lat local/remote_thr perf test [wavded]
  • fixed: tests improved [qubyte, jeremybarnes, ronkorving]
  • fixed: Node v0.9.4+ compatibility [mscdex]
  • fixed: SNDHWM and RCVHWM options were given the wrong type [freehaha]
  • removed: waf support [mscdex]

2.2.0 / 2012-10-17

  • add support for pkg-config
  • add libzmq 3.x support [aaudis]
  • fix: prevent GC happening too soon for connect/bindSync

2.1.0 / 2012-06-29

  • fix require() for 0.8.0
  • change: use uv_poll in place of IOWatcher
  • remove stupid engines field

2.0.3 / 2012-03-14

  • Removed -Wall (libuv unused vars caused the build to fail...)

2.0.2 / 2012-02-16

  • Added back .createSocket() for BC. Closes #86

2.0.1 / 2012-01-26

  • Added .zmqVersion [patricklucas]
  • Fixed multipart support [joshrtay]