Coder Social home page Coder Social logo

zeromq.node's Introduction

zmq   Build Status Build status

ØMQ bindings for node.js.

Project Status

This project has moved!

The same people (and more) who brought you zmq now bring you zeromq, under the official zeromq GitHub organization.

We suggest all users migrate to this fork. Issues and Pull Requests on this (JustinTulloss/zeromq.node) repository will no longer be handled by the core team.

Installation

on Windows:

First install Visual Studio and either Node.js or io.js.

Ensure you're building zmq from a conservative location on disk, one without unusual characters or spaces, for example somewhere like: C:\sources\myproject.

Installing the ZeroMQ library is optional and not required on Windows. We recommend running npm install and node executable commands from a github for windows shell or similar environment.

installing on Unix/POSIX (and osx):

First install pkg-config and the ZeroMQ library.

This module is compatible with ZeroMQ versions 2, 3 and 4. The installation process varies by platform, but headers are mandatory. Most Linux distributions provide these headers with -devel packages like zeromq-devel or zeromq3-devel. Homebrew for OS X provides versions 4 and 3 with packages zeromq and zeromq3, respectively. A Chris Lea PPA is available for Debian-like users who want a version newer than currently provided by their distribution. Windows is supported but not actively maintained.

Note: For zap support with versions >=4 you need to have libzmq built and linked against libsodium. Check the Travis configuration for a list of what is tested and therefore known to work.

with your platform-specifics taken care of, install and use this module:

$ npm install zmq

Examples

Push/Pull

// producer.js
var zmq = require('zmq')
  , 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
var zmq = require('zmq')
  , 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

// pubber.js
var zmq = require('zmq')
  , 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);
// subber.js
var zmq = require('zmq')
  , 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);
});

Monitoring

You can get socket state changes events by calling to the monitor function. The supported events are (see ZMQ docs for full description):

  • connect - ZMQ_EVENT_CONNECTED
  • connect_delay - ZMQ_EVENT_CONNECT_DELAYED
  • connect_retry - ZMQ_EVENT_CONNECT_RETRIED
  • listen - ZMQ_EVENT_LISTENING
  • bind_error - ZMQ_EVENT_BIND_FAILED
  • accept - ZMQ_EVENT_ACCEPTED
  • accept_error - ZMQ_EVENT_ACCEPT_FAILED
  • close - ZMQ_EVENT_CLOSED
  • close_error - ZMQ_EVENT_CLOSE_FAILED
  • disconnect - ZMQ_EVENT_DISCONNECTED

All events get 2 arguments:

  • fd - The file descriptor of the underlying socket (if available)
  • endpoint - The underlying socket endpoint

A special monitor_error event will be raised when there was an error in the monitoring process, after this event no more monitoring events will be sent, you can try and call monitor again to restart the monitoring process.

monitor(interval, numOfEvents)

Will create an inproc PAIR socket where zmq will publish socket state changes events, the events from this socket will be read every interval (defaults to 10ms). By default only 1 message will be read every interval, this can be configured by using the numOfEvents parameter, where passing 0 will read all available messages per interval.

unmonitor()

Stop the monitoring process

example

// Create a socket
var zmq = require('zmq');
socket = zmq.socket('req');

// Register to monitoring events
socket.on('connect', function(fd, ep) {console.log('connect, endpoint:', ep);});
socket.on('connect_delay', function(fd, ep) {console.log('connect_delay, endpoint:', ep);});
socket.on('connect_retry', function(fd, ep) {console.log('connect_retry, endpoint:', ep);});
socket.on('listen', function(fd, ep) {console.log('listen, endpoint:', ep);});
socket.on('bind_error', function(fd, ep) {console.log('bind_error, endpoint:', ep);});
socket.on('accept', function(fd, ep) {console.log('accept, endpoint:', ep);});
socket.on('accept_error', function(fd, ep) {console.log('accept_error, endpoint:', ep);});
socket.on('close', function(fd, ep) {console.log('close, endpoint:', ep);});
socket.on('close_error', function(fd, ep) {console.log('close_error, endpoint:', ep);});
socket.on('disconnect', function(fd, ep) {console.log('disconnect, endpoint:', ep);});

// Handle monitor error
socket.on('monitor_error', function(err) {
	console.log('Error in monitoring: %s, will restart monitoring in 5 seconds', err);
	setTimeout(function() { socket.monitor(500, 0); }, 5000);
});

// Call monitor, check for events every 500ms and get all available events.
console.log('Start monitoring...');
socket.monitor(500, 0);
socket.connect('tcp://127.0.0.1:1234');

setTimeout(function() {
	console.log('Stop the monitoring...');
	socket.unmonitor();
}, 20000);

Detaching from the event loop

You may temporarily disable polling on a specific ZMQ socket and let the node.js process to terminate without closing sockets explicitly by removing their event loop references. Newly created sockets are already ref()-ed.

unref()

Detach the socket from the main event loop of the node.js runtime. Calling this on already detached sockets is a no-op.

ref()

Attach the socket to the main event loop. Calling this on already attached sockets is a no-op.

Example

var zmq = require('zmq');
socket = zmq.socket('sub');
socket.bindSync('tcp://127.0.0.1:1234');
socket.subscribe('');
socket.on('message', function(msg) { console.log(msg.toString(); });
// Here blocks indefinitely unless interrupted.
// Let it terminate after 1 second.
setTimeout(function() { socket.unref(); }, 1000);

Running tests

Install dev deps:

$ git clone https://github.com/JustinTulloss/zeromq.node.git zmq && cd zmq
$ npm i

Build:

# on unix:
$ make

# building on windows:
> npm i

Test:

# on unix:
$ make test

# testing on windows:
> npm t

Running benchmarks

Benchmarks are available in the perf directory, and have been implemented according to the zmq documentation: How to run performance tests

In the following examples, the arguments are respectively:

  • the host to connect to/bind on
  • message size (in bytes)
  • message count

You can run a latency benchmark by running these two commands in two separate shells:

node ./local_lat.js tcp://127.0.0.1:5555 1 100000
node ./remote_lat.js tcp://127.0.0.1:5555 1 100000

And you can run throughput tests by running these two commands in two separate shells:

node ./local_thr.js tcp://127.0.0.1:5555 1 100000
node ./remote_thr.js tcp://127.0.0.1:5555 1 100000

Running make perf will run the commands listed above.

zeromq.node's People

Contributors

aaudis avatar achimnol avatar alexeykupershtokh avatar bluebery avatar briansneddon avatar coreyjewett avatar cxreg avatar f34rdotcom avatar jeremybarnes avatar joshrtay avatar justintulloss avatar kkoopa avatar lgeiger avatar mgc avatar mlc avatar mojodna avatar mscdex avatar msealand avatar patricklucas avatar rasky avatar reqshark avatar ronkorving avatar soplwang avatar sshirokov avatar tj avatar utvara avatar valyouw avatar wavded avatar xla avatar yoneal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zeromq.node's Issues

Windows support would be awesome

I understand if you consider this low prio, especially until the whole procedure around node/npm on windows is settled, but it would be a great way to interop between node and .Net applications.

Does this library support the many-many pattern?

Hello,
I just wanted to know if the library supports the many-many pattern. Was checking the code (not very familiar with either 0mq or C++ bindings for node.js), but was wondering what Socket._fd would return for a many-many 0mq socket? I mean if the IOWatcher can watch just a single FD, and data can come in on multiple sockets (can it?), how will the events be triggered?

another zmq installation error

Tried installing it on CentOS, and here's what I get..

npm http GET https://registry.npmjs.org/zmq/2.0.0
npm http 200 https://registry.npmjs.org/zmq/2.0.0
npm ERR! Error: UNKNOWN, unknown error '/tmp/npm-1324400604608'
npm ERR! Report this entire log at:
npm ERR! http://github.com/isaacs/npm/issues
npm ERR! or email it to:
npm ERR! [email protected]
npm ERR!
npm ERR! System Linux 2.6.32-131.21.1.el6.x86_64
npm ERR! command "node" "/usr/local/bin/npm" "install" "[email protected]"
npm ERR! cwd /root/Projects/testapp
npm ERR! node -v v0.6.6
npm ERR! npm -v 1.1.0-beta-4
npm ERR! path /tmp/npm-1324400604608
npm ERR! code UNKNOWN
npm ERR! message UNKNOWN, unknown error '/tmp/npm-1324400604608'
npm ERR! Error: UNKNOWN, unknown error 'npm-debug.log'
npm ERR! Report this entire log at:
npm ERR! http://github.com/isaacs/npm/issues
npm ERR! or email it to:
npm ERR! [email protected]
npm ERR!
npm ERR! System Linux 2.6.32-131.21.1.el6.x86_64
npm ERR! command "node" "/usr/local/bin/npm" "install" "[email protected]"
npm ERR! cwd /root/Projects/testapp
npm ERR! node -v v0.6.6
npm ERR! npm -v 1.1.0-beta-4
npm ERR! path npm-debug.log
npm ERR! code UNKNOWN
npm ERR! message UNKNOWN, unknown error 'npm-debug.log'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /root/Projects/testapp/npm-debug.log
npm not ok

Any docs?

Where I can find any docs or examples?

Ubuntu 10.10 issues?

Had no problems on a 32 bit 10.04 box using this tutorial: http://johanharjono.com/archives/633. I can run 'server.js' and get a listener who pulls. Everything installs fine on a 32 bit 10.10 box, but when I run 'node client.js', I get this error:

node: symbol lookup error: /usr/local/lib/node/.npm/zeromq/0.4.0/package/binding.node: undefined symbol: zmq_init

Please help!

require fails

require('zeromq');

results in this error:
/libexec/ld-elf.so.1: /root/node_modules/zeromq/binding.node: Undefined symbol "_ZN2v811HandleScopeC1Ev"

OS:BSD, NODE V 0.4.8, zeromq.node version 0.5.0

Any thoughts? Would really like to use this in a production application,,, but cant seem to get things working.
npm install went off without a hitch, but cant require the lib without error.....

Thanks,

require 'zeromq' -> 'zmq'

The samples in the readme still point to (possibly?) old naming?

Replacing require 'zeromq' to 'zmq' makes them work again.

zmq install failed

Rafals-MacBook:myproject rav$ node -v
v0.6.2

Rafals-MacBook:myproject rav$ npm -v
1.0.106

Rafals-MacBook:myproject rav$ brew list zeromq
/usr/local/Cellar/zeromq/2.1.10/include/ (3 files)
/usr/local/Cellar/zeromq/2.1.10/lib/libzmq.1.dylib
/usr/local/Cellar/zeromq/2.1.10/lib/pkgconfig/libzmq.pc
/usr/local/Cellar/zeromq/2.1.10/lib/ (2 other files)
/usr/local/Cellar/zeromq/2.1.10/share/man/ (30 files)

Rafals-MacBook:myproject rav$ npm install zmq

> [email protected] preinstall /Users/rav/Documents/myproject/node_modules/zmq
> node-waf clean || true; node-waf configure build

Nothing to clean (project not configured)
Setting srcdir to                        : /Users/rav/Documents/myproject/node_modules/zmq 
Setting blddir to                        : /Users/rav/Documents/myproject/node_modules/zmq/build 
Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : not found 
Checking for node prefix                 : ok /usr/local/Cellar/node/0.6.2 
Checking for pkg-config version >= 0.0.0 : pkg-config was not found 
/Users/rav/Documents/myproject/node_modules/zmq/wscript:14: error: the configuration failed (see '/Users/rav/Documents/myproject/node_modules/zmq/build/config.log')
npm ERR! error installing [email protected] Error: [email protected] preinstall: `node-waf clean || true; node-waf configure build`
npm ERR! error installing [email protected] `sh "-c" "node-waf clean || true; node-waf configure build"` failed with 1
npm ERR! error installing [email protected]     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected]     at ChildProcess.emit (events.js:70:17)
npm ERR! error installing [email protected]     at maybeExit (child_process.js:359:16)
npm ERR! error installing [email protected]     at Process.onexit (child_process.js:395:5)
npm ERR! [email protected] preinstall: `node-waf clean || true; node-waf configure build`
npm ERR! `sh "-c" "node-waf clean || true; node-waf configure build"` failed with 1
npm ERR! 
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the zmq package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-waf clean || true; node-waf configure build
npm ERR! You can get their info via:
npm ERR!     npm owner ls zmq
npm ERR! There is likely additional logging output above.
npm ERR! 
npm ERR! System Darwin 11.2.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "zmq"
npm ERR! cwd /Users/rav/Documents/myproject
npm ERR! node -v v0.6.2
npm ERR! npm -v 1.0.106
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/rav/Documents/myproject/npm-debug.log
npm not ok

Issues with inproc && pubsub

I don't know if this is an issue with the driver, with zeromq or if I'm doing something wrong. Anyway, the pub/sub within an 'inproc' is not working at all, however if I change address to an tcp address it does work, also xrep andrep works perfectly fine with 'inproc'.

var ZMQ = require('zeromq');
var Broadcast = ZMQ.createSocket('pub');

var address = 'inproc://foobar';
Broadcast.bind(address, function(err) {
    if (err) {
        throw err;
    }
    var repeater = ZMQ.createSocket('sub');
    repeater.connect(address);
    repeater.subscribe('');
    repeater.on('message', function (message) {
        console.log(message.toString());
    });
    setInterval(function() {
        Broadcast.send('foo');
    }, 1000);
});

Am I doing something wrong?

Cheers,

SlowBuffer

Hi,
I am trying to write a test client and I am getting the following output:

SlowBuffer 59 6f 75 20 61 72 65 20 63 6f 6e 6e 65 63 74 65 64 20 74 6f 20 74 68 65 20 73 6f 63 6b 65 74 20 73 65 72 76 65 72

Here is my client:

var context = require('zeromq');

console.log('Connecting...');
var requester = context.createSocket('req');

requester.on('message', function(response){
    console.log('RESPONSE', response);
});

requester.on('error', function (response){
    console.log('ERROR', response);
});

requester.connect("tcp://localhost:5555");

//requester.sendBufferSize = 2408;

console.log('[INFO]', requester.sendBufferSize);

/*
 * You must convert the JSON object to a string
 */
requester.send(new Buffer("Test"));

process.on('SIGINT', function() {
    requester.close()
})

Here is my server:

bind('tcp://*:5555');

while (true)
{
    $request = $responder->recv();
    $responder->send("You are connected to the socket server");
}

?>

I have a PHP client thats working correctly so I am pretty confident the underlying systems are working properly.

node version = 0.4.9
omq version = 2.1.9
php version = 5.2

Any ideas or suggestions would be appreciated.

Thanks
Steve

CPU hog

I'd like to use zeromq.node for a project I'm working on, but even the minimal script in the gist below causes node to spin up 100% CPU on two of my boxes I have handy:

Code: http://gist.github.com/581780

Centos 5.5, Linux 2.6.36-rc4, Node v0.2.1, ZMQ 2.0.9:

[root@centos5 ~]# ./node-zmq-test.js
Context() created.
Socket() created.
connected
sent buffer on socket
^C

Gentoo 2.6.34-x86_64-linode14, Node v0.2.0, ZMQ (git head / 2.0.10):

user@gentoo:~/src$ node node-zmq-test.js
Context() created.
Socket() created.
connected
sent buffer on socket
node: /opt/node/include/node/node_object_wrap.h:29: static T* node::ObjectWrap::Unwrap(v8::Handlev8::Object) [with T = node::Buffer]: Assertion `handle->InternalFieldCount() > 0' failed.
Aborted

Symbol not found: _zmq_init

Updated to 0.4.0 and get the follow error. I have reinstalled zeromq mulitple times and also rebuilt node-zeromq. Any ideas?

require("zeromq").createSocket("req")
dyld: lazy symbol binding failed: Symbol not found: _zmq_init
Referenced from: /usr/local/lib/node/.npm/zeromq/0.4.0/package/binding.node
Expected in: flat namespace

dyld: Symbol not found: _zmq_init
Referenced from: /usr/local/lib/node/.npm/zeromq/0.4.0/package/binding.node
Expected in: flat namespace

Trace/BPT trap

another zmq installation error

Tried installing it on CentOS, and here's what I get..

Nothing to clean (project not configured)
Setting srcdir to : /root/Projects/testapp/node_modules/zmq
Setting blddir to : /root/Projects/testapp/node_modules/zmq/build
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for node path : not found
Checking for node prefix : ok /usr/local
Checking for pkg-config version >= 0.0.0 : yes
Checking for libzmq >= 2.1.0 : Package libzmq was not found
/root/Projects/testapp/node_modules/zmq/wscript:15: error: the configuration failed (see '/root/Projects/testapp/node_modules/zmq/build/config.log')
npm ERR! error installing [email protected]
npm ERR! [email protected] preinstall: node-waf clean || (exit 0); node-waf configure build
npm ERR! sh "-c" "node-waf clean || (exit 0); node-waf configure build" failed with 1
npm ERR!
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the zmq package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-waf clean || (exit 0); node-waf configure build
npm ERR! You can get their info via:
npm ERR! npm owner ls zmq
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System Linux 2.6.32-131.21.1.el6.x86_64
npm ERR! command "node" "/usr/local/bin/npm" "install" "zmq"
npm ERR! cwd /root/Projects/testapp
npm ERR! node -v v0.6.6
npm ERR! npm -v 1.1.0-beta-4
npm ERR! code ELIFECYCLE
npm ERR! message [email protected] preinstall: node-waf clean || (exit 0); node-waf configure build
npm ERR! message sh "-c" "node-waf clean || (exit 0); node-waf configure build" failed with 1
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /root/Projects/testapp/npm-debug.log
npm not ok

Support for zeromq 3.0

Support all the changes in zeromq 3.0. Hopefully it wouldn't take too long.

Thanks

Ollie

Build failure with 1.0.3, 1.0.2 still builds fine

$ npm install [email protected]

> [email protected] preinstall /private/tmp/node_modules/zmq
> node-waf clean || true; node-waf configure build

Nothing to clean (project not configured)
Setting srcdir to                        : /private/tmp/node_modules/zmq 
Setting blddir to                        : /private/tmp/node_modules/zmq/build 
Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : ok /usr/local/lib/node_modules 
Checking for node prefix                 : ok /usr/local/Cellar/node/0.4.12 
Checking for pkg-config version >= 0.0.0 : yes 
Checking for libzmq >= 2.1.0             : yes 
Checking for library uuid                : not found 
'configure' finished successfully (0.133s)
Waf: Entering directory `/private/tmp/node_modules/zmq/build'
[1/2] cxx: binding.cc -> build/default/binding_1.o
[2/2] cxx_link: build/default/binding_1.o -> build/default/binding.node
Waf: Leaving directory `/private/tmp/node_modules/zmq/build'
'build' finished successfully (0.548s)
Traceback (most recent call last):
  File "/usr/local/bin/node-waf", line 16, in <module>
    Scripting.prepare(t, os.getcwd(), VERSION, wafdir)
  File "/usr/local/Cellar/node/0.4.12/bin/../lib/node/wafadmin/Scripting.py", line 145, in prepare
    prepare_impl(t, cwd, ver, wafdir)
  File "/usr/local/Cellar/node/0.4.12/bin/../lib/node/wafadmin/Scripting.py", line 135, in prepare_impl
    main()
  File "/usr/local/Cellar/node/0.4.12/bin/../lib/node/wafadmin/Scripting.py", line 186, in main
    fun()
  File "/private/tmp/node_modules/zmq/wscript", line 30, in shutdown
    link('./build/Release/binding.node', './binding.node')
OSError: [Errno 2] No such file or directory
npm ERR! error installing [email protected] Error: [email protected] preinstall: `node-waf clean || true; node-waf configure build`
npm ERR! error installing [email protected] `sh "-c" "node-waf clean || true; node-waf configure build"` failed with 1
npm ERR! error installing [email protected]     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected]     at ChildProcess.emit (events.js:67:17)
npm ERR! error installing [email protected]     at ChildProcess.onexit (child_process.js:192:12)
npm ERR! [email protected] preinstall: `node-waf clean || true; node-waf configure build`
npm ERR! `sh "-c" "node-waf clean || true; node-waf configure build"` failed with 1
npm ERR! 
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the zmq package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-waf clean || true; node-waf configure build
npm ERR! You can get their info via:
npm ERR!     npm owner ls zmq
npm ERR! There is likely additional logging output above.
npm ERR! 
npm ERR! System Darwin 11.2.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "[email protected]"
npm ERR! cwd /private/tmp
npm ERR! node -v v0.4.12
npm ERR! npm -v 1.0.104
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /private/tmp/npm-debug.log
npm not ok

$ npm install [email protected] works fine:

$ npm install [email protected]

> [email protected] preinstall /private/tmp/node_modules/zmq
> node-waf clean || true; node-waf configure build

Nothing to clean (project not configured)
Setting srcdir to                        : /private/tmp/node_modules/zmq 
Setting blddir to                        : /private/tmp/node_modules/zmq/build 
Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : ok /usr/local/lib/node_modules 
Checking for node prefix                 : ok /usr/local/Cellar/node/0.4.12 
Checking for pkg-config version >= 0.0.0 : yes 
Checking for libzmq >= 2.1.0             : yes 
'configure' finished successfully (0.074s)
Waf: Entering directory `/private/tmp/node_modules/zmq/build'
[1/2] cxx: binding.cc -> build/default/binding_1.o
[2/2] cxx_link: build/default/binding_1.o -> build/default/binding.node
Waf: Leaving directory `/private/tmp/node_modules/zmq/build'
'build' finished successfully (0.565s)
[email protected] ./node_modules/zmq

Problems when requiring zeromq

I have 0MQ 2.1.0 installed, and node.js 3.2, but this node.js binding isn't working for me:

> require('zeromq')
Error: libzmq.so.1: cannot open shared object file: No such file or directory
    at Object..node (node.js:371:15)
    at Module.load (node.js:288:27)
    at loadModule (node.js:260:14)
    at require (node.js:300:16)
    at Object.<anonymous> (/usr/local/lib/node/.npm/zeromq/0.3.0/package/zeromq.js:5:11)
    at Module._compile (node.js:357:32)
    at Object..js (node.js:365:14)
    at Module.load (node.js:288:27)
    at loadModule (node.js:260:14)
    at require (node.js:300:16)

To be fair, I've gotten a very similar error message when trying to use the Ruby zmq bindings. However, chicken-scheme bindings work fine for me, so I can confirm that 0MQ 2.1.0 itself has definitely installed fine on my system.

Failed to install zmq on node 0.6.0

sudo npm install -g zmq

> [email protected] preinstall /usr/local/lib/node_modules/zmq
> node-waf clean || true; node-waf configure build

Nothing to clean (project not configured)
Setting srcdir to                        : /usr/local/lib/node_modules/zmq 
Setting blddir to                        : /usr/local/lib/node_modules/zmq/build 
Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : ok /home/johnleco/.node_libraries 
Checking for node prefix                 : ok /usr/local 
Checking for pkg-config version >= 0.0.0 : yes 
Checking for libzmq >= 2.1.0             : yes 
'configure' finished successfully (0.056s)
Waf: Entering directory `/usr/local/lib/node_modules/zmq/build'
[1/2] cxx: binding.cc -> build/Release/binding_1.o
../binding.cc: In static member function 'static v8::Handle<v8::Value> zmq::Socket::Bind(const v8::Arguments&)':
../binding.cc:443:64: error: invalid conversion from 'int (*)(eio_req*)' to 'void (*)(eio_req*)'
../binding.cc:443:64: error:   initializing argument 1 of 'eio_req* eio_custom(void (*)(eio_req*), int, int (*)(eio_req*), void*)'
Waf: Leaving directory `/usr/local/lib/node_modules/zmq/build'
Build failed:  -> task failed (err #1): 
        {task: cxx binding.cc -> binding_1.o}
npm ERR! error installing [email protected] Error: [email protected] preinstall: `node-waf clean || true; node-waf configure build`
npm ERR! error installing [email protected] `sh "-c" "node-waf clean || true; node-waf configure build"` failed with 1
npm ERR! error installing [email protected]     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected]     at ChildProcess.emit (events.js:70:17)
npm ERR! error installing [email protected]     at maybeExit (child_process.js:359:16)
npm ERR! error installing [email protected]     at Process.onexit (child_process.js:395:5)
npm ERR! [email protected] preinstall: `node-waf clean || true; node-waf configure build`
npm ERR! `sh "-c" "node-waf clean || true; node-waf configure build"` failed with 1
npm ERR! 
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the zmq package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-waf clean || true; node-waf configure build
npm ERR! You can get their info via:
npm ERR!     npm owner ls zmq
npm ERR! There is likely additional logging output above.
npm ERR! 
npm ERR! System Linux 2.6.38-11-generic
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "zmq"
npm ERR! cwd /home/johnleco/develop/bugbuster-server
npm ERR! node -v v0.6.0
npm ERR! npm -v 1.0.104
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/johnleco/develop/bugbuster-server/npm-debug.log
npm not ok

install w/o root privileges

Hi!

it's impossible to npm install this repo unless you have got system wide libzmq-dev installed (debian-ly speaking) or you've root privileges to sudo make install libzmq from scratch.

While it's easy to override libzmq headers location by running PKG_CONFIG_PATH=/path/of/your/local/libzmq/build/src CXXFLAGS="-I/path/of/your/local/libzmq/build/include" node-waf configure build, node-waf seems to not honor passed LINKFLAGS=/path/of/your/local/libzmq/build/src/.libs to specify custom libraries location, which results in failing by not finding -lzmq.

Please, consider adding maybe a special target which could download and use libzmq sources locally.

TIA,
--Vladimir

pubsub speed issues?

Howdy,

What kind of message per second speed do you normally see with zeromq on nodejs? I was doing some testing with your binding and cannot seem to get above a few hundred per second. Is this what you normally see? I was using publish

see below for my publish server

https://gist.github.com/907514

v/r

-Tim

Do you have to send a string?

It would be nice if I could send objects directly across the wire. The JSON.stringify and JSON.parse is pretty slow. Any thoughts here?

"Socket is closed" errors

I'm seeing a lot of errors like this:

TypeError: Socket is closed
    at [object Object]._ioevents (/data/nodeload/node_modules/zeromq/zeromq.js:79:22)
    at [object Object]._flush (/data/nodeload/node_modules/zeromq/zeromq.js:181:21)
    at [object Object].send (/data/nodeload/node_modules/zeromq/zeromq.js:160:8)
    at Object.incr (/data/nodeload/lib/stats.js:25:17)

I have a hunch it has to do with a stat being incremented before the socket has connected properly. Will do some more digging.

The incr() function sends data over a PUSH socket every time someone downloads a tarball from GitHub:

exports.incr = (data) ->
  if !(data?.repo? and data.commitish?) or data.commitish == data.commit
    return

  now    = new Date
  prefix = "stats:nodeload"
  key    = "#{prefix}:#{now.getFullYear()}:#{now.getMonth()+1}:#{now.getDate()}"
  repo   = "repo:#{data.repo}"
  field  = "#{repo}:#{data.commitish}"
  data   = {}
  data[prefix] = count: 1
  data[key]    = count: 1
  data[prefix][repo]  = 1
  data[key][repo]     = 1
  data[key][field]    = 1

  socket.send JSON.stringify(data)

program sometimes ends even with active listener

The following code doesn't listen on the socket forever and should

var socket = zeromq.createSocket('pull');
socket.connect('tcp://127.0.0.1:45670');
socket.on('message', function(message) {
   // do stuff with the message
});
util.puts('Ready to serve.');

Segfault

Segfault at 2.0.8 ZeroMQ and 0.2 NodeJS if run test script (after new zmq.Socket call)

unable to build / install

Hi,

I'm trying to install the module, but run into the following error message:

marco@nodedev:~/code/trackerd$ npm install zeromq

[email protected] preinstall /home/marco/code/trackerd/node_modules/zeromq
node-waf clean || true; node-waf configure build

Nothing to clean (project not configured)
Setting srcdir to : /home/marco/code/trackerd/node_modules/zeromq
Setting blddir to : /home/marco/code/trackerd/node_modules/zeromq/build
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for node path : ok /home/marco/.node_libraries
Checking for node prefix : ok /usr/local
Checking for libzmq : not found
'configure' finished successfully (0.169s)
Waf: Entering directory /home/marco/code/trackerd/node_modules/zeromq/build' [1/2] cxx: binding.cc -> build/default/binding_1.o cc1plus: warnings being treated as errors /usr/local/include/node/ev.h:565:1: error: ‘ev_tstamp ev_now()’ defined but not used /usr/local/include/node/ev.h:574:1: error: ‘int ev_is_default_loop()’ defined but not used /usr/local/include/node/ev.h:810:20: error: ‘void ev_loop(int)’ defined but not used /usr/local/include/node/ev.h:811:20: error: ‘void ev_unloop(int)’ defined but not used /usr/local/include/node/ev.h:812:20: error: ‘void ev_default_destroy()’ defined but not used /usr/local/include/node/ev.h:813:20: error: ‘void ev_default_fork()’ defined but not used /usr/local/include/node/ev.h:815:30: error: ‘unsigned int ev_loop_count()’ defined but not used /usr/local/include/node/ev.h:816:30: error: ‘unsigned int ev_loop_depth()’ defined but not used /usr/local/include/node/ev.h:817:30: error: ‘void ev_loop_verify()’ defined but not used Waf: Leaving directory/home/marco/code/trackerd/node_modules/zeromq/build'

I have node 0.4.7 installed from a git clone, and libzmq 2.1.7 verified to work by using other bindings (like Python). The system is Linux Ubuntu 11.04 Server.

Any ideas? Thanks in advance!

npm install zmq on windows error

I try to install zmq on windows, however, it reports some error:

PS C:\program files\nodejs> npm install zmq

[email protected] preinstall C:\program files\nodejs\node_modules\zmq
node-waf clean || true; node-waf configure build

'node-waf' is not recognized as an internal or external command,
operable program or batch file.
'true' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! error installing [email protected] Error: [email protected] preinstall: node-waf clean || true; node-waf configure build
npm ERR! error installing [email protected] cmd "/c" "node-waf clean || true; node-waf configure build" failed with 1
npm ERR! error installing [email protected] at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\lib\utils
exec.js:49:20)
npm ERR! error installing [email protected] at ChildProcess.emit (events.js:70:17)
npm ERR! error installing [email protected] at maybeExit (child_process.js:359:16)
npm ERR! error installing [email protected] at Process.onexit (child_process.js:395:5)
npm ERR! [email protected] preinstall: node-waf clean || true; node-waf configure build
npm ERR! cmd "/c" "node-waf clean || true; node-waf configure build" failed with 1
npm ERR!
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the zmq package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-waf clean || true; node-waf configure build
npm ERR! You can get their info via:
npm ERR! npm owner ls zmq
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System Windows_NT 6.0.6002
npm ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js"
"install" "zmq"
npm ERR! cwd C:\program files\nodejs
npm ERR! node -v v0.6.6
npm ERR! npm -v 1.0.106
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\program files\nodejs\npm-debug.log
npm not ok

Symbol not found: _zmq_init

Hi -

Trying to use zeromq.node and while the install works fine I get an error as soon as a try and create a socket. I'm suing 0MQ v2.1.7 on OS X Lion.

Here's the code that's failing:

var zmq = require('zmq');
var socket = zmq.createSocket('req');

When I run it I get the following output:

$ node server.js
Starting server on port 8888
dyld: lazy symbol binding failed: Symbol not found: _zmq_init
Referenced from: /usr/local/lib/node_modules/zmq/binding.node
Expected in: flat namespace

dyld: Symbol not found: _zmq_init
Referenced from: /usr/local/lib/node_modules/zmq/binding.node
Expected in: flat namespace

Trace/BPT trap: 5

Any ideas?

Note that if I take out the createSocket() call it works so the module is being properly loaded, it just won't work if you try and interact with the context.

Thx
Mike

troubles with zmq.node and recent build of zmq?

Here is my console output. I installed zmq from tarball this morning and seemed like it was working with npm install zeromq, but zmq causes problems. Not sure why the installer is not finding my libzmq?

tony-wonder:workspace shane$ npm install zmq

[email protected] preinstall /Users/shane/workspace/node_modules/zmq
node-waf clean || true; node-waf configure build

Nothing to clean (project not configured)
Setting srcdir to : /Users/shane/workspace/node_modules/zmq
Setting blddir to : /Users/shane/workspace/node_modules/zmq/build
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for node path : not found
Checking for node prefix : ok /Users/shane/local/node
Checking for libzmq >= 2.1.0 : no
'configure' finished successfully (0.114s)
Waf: Entering directory /Users/shane/workspace/node_modules/zmq/build' [1/2] cxx: binding.cc -> build/default/binding_1.o [2/2] cxx_link: build/default/binding_1.o -> build/default/binding.node Waf: Leaving directory/Users/shane/workspace/node_modules/zmq/build'
'build' finished successfully (0.655s)
[email protected] ./node_modules/zmq
tony-wonder:workspace shane$ node

zmq = require('zmq')
{ createSocket: [Function] }
socket = zmq.createSocket('req');
dyld: lazy symbol binding failed: Symbol not found: _zmq_init
Referenced from: /Users/shane/workspace/node_modules/zmq/binding.node
Expected in: flat namespace

dyld: Symbol not found: _zmq_init
Referenced from: /Users/shane/workspace/node_modules/zmq/binding.node
Expected in: flat namespace

Trace/BPT trap

Name of project

Hi Justin,

A minor point, but the convention for language bindings is to use the 'zmq' name instead of 'ZeroMQ', to match the library name ('libzmq'). We use 'ZeroMQ' more and more to describe the whole community of projects.

We renamed the library from zeromq to libzmq for this reason. Any chance you can rename the node to zmq.node?

Cheers
Pieter

Integrate zeroMQ and Logic Bussniess problem?

Hi Justin, I have a app used zeroMQ module and Socket.Io module.
I want to implement from use input keyword transfer to controller and to zmq.
but in example, scoket.send only just in socket.bind.
I want to run one time the scoket.bind function, and abstract scoket.send function.
But I don't know do that.

For example:
---controller.js(express)
exports.search = function(req, res, next) {
var key = req.params.key;
// send msg to ZMQ (request-reply partten)

   -- But When run this, App Error: "TypeError: Socket is busy."
    xreply(key);        
res.redirect('result/' + service + '/' + encodekey);

};

Do you have this simple example for this?

exports.xreply = function(msg) {

var socketMQ = zeromq.createSocket('xreply');
socketMQ.identity = "server";
socketMQ.bind("tcp://127.0.0.1:5502", function(err) {
    if (err)
        throw err;
    console.log("------zmq server has bound!---------");
    socketMQ.on('message', function(envelope, blank, data) {
        console
                .log("Received: " + envelope + " - "
                        + data.toString('utf8'));
    });
    socketMQ.on('error', function(err) {
        console.log("Error: " + err);
    });
});

var serviceList = config.service_list;
return function(sendMsg) {
    if (msg !== null && msg !== 'undefined') {
        // send service list
        for ( var index in serviceList) {
            this.socketMQ.send(serviceList[index], '' + msg);
        }
    }
}

};

Thank you very much. Please help me.

ZMQ_NOBLOCK not available

Seem that I can't set options on send as reported by zmq documentation. Looking at the code seems that all paramenters of the send are treated as message parts, while the last one should be the options for the send.

Can you confirm this? Is a design decision?

Fabrizio

Socket lost after a time

Hey,

I'm getting an error while connected to a zmq socket, so after a given time I'm getting
Assertion failed: (socket_ == NULL), function ~Socket, file ../zeromq.cc, line 475.
Abort trap
Not sure what's causing it, and the time until I get it varies. I'm unable to catch and treat this exception.

req/rep order

When using zeromq from c, req sockets don't allow sending twice.
The usage pattern is send, receive, send, receive ...
Receive is a blocking call.

Now, zeromq.node of course doesn't want to block and there isn't an explicit receive.
So it allows us to keep on sending. Because 0mq would normally throw an exception when sending twice before receiving, I'm assuming zeromq.node caches additional messages internally and waits for an answer before submitting the next.

This is nice, but I lose the ability to match an answer to a question.
Every reply will reach me through the same callback (socket.on('message', callback));
So I need to create queues where requesting code puts a callback in the queue, and the 1 on-message callback picks the first callback out of the queue and delegates there.

While this works, I don't think it's very nice to do this way.

How about something like:

var request = "3 + 3";
socket.send(request, function(reply) {
console.log(request, '=', reply);
});

Of course I can build a small wrapper lib myself, but I think this should be part of the zeromq.node api.

Do you agree? Or am I just doing something wrong here? :)

build error (node 0.6.0 compatibility?)

I'm on Ubuntu 11.10, just installed libzmq-dev (2.1.9-1), and I get this error when trying to install zeromq through npm:

[1/2] cxx: binding.cc -> build/Release/binding_1.o
../binding.cc:24:16: fatal error: ev.h: No such file or directory
compilation terminated.
Waf: Leaving directory `/home/max/Dropbox/Javascript/colony/node_modules/zeromq/build'
Build failed:  -> task failed (err #1): 
    {task: cxx binding.cc -> binding_1.o}
npm ERR! error installing [email protected] Error: [email protected] preinstall: `node-waf clean || true; node-waf configure build`
npm ERR! error installing [email protected] `sh "-c" "node-waf clean || true; node-waf configure build"` failed with 1
npm ERR! error installing [email protected]     at ChildProcess.<anonymous> (/home/max/local/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected]     at ChildProcess.emit (events.js:70:17)
npm ERR! error installing [email protected]     at maybeExit (child_process.js:359:16)
npm ERR! error installing [email protected]     at Process.onexit (child_process.js:395:5)
npm ERR! [email protected] preinstall: `node-waf clean || true; node-waf configure build`
npm ERR! `sh "-c" "node-waf clean || true; node-waf configure build"` failed with 1
...
npm ERR! node -v v0.6.0
npm ERR! npm -v 1.0.104
npm ERR! code ELIFECYCLE

zmq install failed

This is the error that I'm getting while installing zeromq for node.js.. (platform: Ubuntu 10.10)

'configure' finished successfully (0.286s)
Waf: Entering directory ~/Projects/njs/node_modules/zeromq/build' [1/2] cxx: binding.cc -> build/default/binding_1.o ../binding.cc: In static member function ‘static v8::Handle<v8::Value> zmq::Socket::GetSockOpt(const v8::Arguments&)’: ../binding.cc:343:10: error: ‘ZMQ_EVENTS’ was not declared in this scope ../binding.cc:345:10: error: ‘ZMQ_FD’ was not declared in this scope ../binding.cc:346:10: error: ‘ZMQ_TYPE’ was not declared in this scope ../binding.cc:347:10: error: ‘ZMQ_LINGER’ was not declared in this scope ../binding.cc:348:10: error: ‘ZMQ_RECONNECT_IVL’ was not declared in this scope ../binding.cc:349:10: error: ‘ZMQ_BACKLOG’ was not declared in this scope ../binding.cc: In static member function ‘static v8::Handle<v8::Value> zmq::Socket::SetSockOpt(const v8::Arguments&)’: ../binding.cc:387:10: error: ‘ZMQ_LINGER’ was not declared in this scope ../binding.cc:388:10: error: ‘ZMQ_RECONNECT_IVL’ was not declared in this scope ../binding.cc:389:10: error: ‘ZMQ_BACKLOG’ was not declared in this scope ../binding.cc:392:10: error: ‘ZMQ_EVENTS’ was not declared in this scope ../binding.cc:393:10: error: ‘ZMQ_FD’ was not declared in this scope ../binding.cc:394:10: error: ‘ZMQ_TYPE’ was not declared in this scope ../binding.cc: In function ‘void zmq::Initialize(v8::Handle<v8::Object>)’: ../binding.cc:780:5: error: ‘ZMQ_FD’ was not declared in this scope ../binding.cc:781:5: error: ‘ZMQ_EVENTS’ was not declared in this scope ../binding.cc:782:5: error: ‘ZMQ_TYPE’ was not declared in this scope ../binding.cc:783:5: error: ‘ZMQ_LINGER’ was not declared in this scope ../binding.cc:784:5: error: ‘ZMQ_RECONNECT_IVL’ was not declared in this scope ../binding.cc:785:5: error: ‘ZMQ_BACKLOG’ was not declared in this scope Waf: Leaving directory/Projects/njs/node_modules/zeromq/build'
Build failed: -> task failed (err #1):
{task: cxx binding.cc -> binding_1.o}
npm ERR! error installing [email protected] Error: [email protected] preinstall: node-waf clean || true; node-waf configure build
npm ERR! error installing [email protected] sh "-c" "node-waf clean || true; node-waf configure build" failed with 1
npm ERR! error installing [email protected] at ChildProcess. (
/Projects/njs/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected] at ChildProcess.emit (events.js:67:17)
npm ERR! error installing [email protected] at ChildProcess.onexit (child_process.js:192:12)
npm ERR! [email protected] preinstall: node-waf clean || true; node-waf configure build
npm ERR! sh "-c" "node-waf clean || true; node-waf configure build" failed with 1
npm ERR!
npm ERR! Failed at the [email protected] preinstall 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! node-waf clean || true; node-waf configure build
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!
npm ERR! System Linux 2.6.38-11-generic
npm ERR! command "node" "~/Projects/njs/bin/npm" "install" "zeromq"
npm ERR! cwd ~/Projects/njs
npm ERR! node -v v0.4.8
npm ERR! npm -v 1.0.103
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! ~/Projects/njs/npm-debug.log
npm not ok

compile error

$ node -v
v0.1.102

$ node-waf configure clean build
Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : ok /Users/rick/.node_libraries 
Checking for node prefix                 : ok /usr/local 
'configure' finished successfully (0.043s)
'clean' finished successfully (0.023s)
Waf: Entering directory `/Users/rick/p/zeromq.node/build'
[1/2] cxx: zeromq.cc -> build/default/zeromq_1.o
../zeromq.cc: In static member function ‘static v8::Handle<v8::Value> zmq::Socket::Recv(const v8::Arguments&)’:
../zeromq.cc:290: error: conversion from ‘zmq::Message*’ to non-scalar type ‘v8::Handle<v8::Value>’ requested
Waf: Leaving directory `/Users/rick/p/zeromq.node/build'
Build failed:  -> task failed (err #1): 
    {task: cxx zeromq.cc -> zeromq_1.o}

Do I need a custom prefix for zeromq? I installed it with homebrew:

$ brew list zeromq
/usr/local/Cellar/zeromq/2.0.7/bin/zmq_streamer
/usr/local/Cellar/zeromq/2.0.7/bin/zmq_queue
/usr/local/Cellar/zeromq/2.0.7/bin/zmq_forwarder
/usr/local/Cellar/zeromq/2.0.7/include/ (2 files)
/usr/local/Cellar/zeromq/2.0.7/lib/libzmq.0.dylib
/usr/local/Cellar/zeromq/2.0.7/lib/pkgconfig/libzmq.pc
/usr/local/Cellar/zeromq/2.0.7/lib/ (2 other files)
/usr/local/Cellar/zeromq/2.0.7/share/man/ (32 files)

$ which zmq_queue
/usr/local/bin/zmq_queue

Pubsub example in examples folder

Hi Justin,

Would you be willing to make a pub/sub example?

I've had no luck in getting this to work with the latest zmq and node versions.

Thanks

unable to install on ubuntu

jigar@jigar-desktop:~$ npm install zeromq -g

[email protected] preinstall /home/jigar/local/node/lib/node_modules/zeromq
node-waf clean || true; node-waf configure build

Nothing to clean (project not configured)
Setting srcdir to : /home/jigar/local/node/lib/node_modules/zeromq
Setting blddir to : /home/jigar/local/node/lib/node_modules/zeromq/build
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for node path : not found
Checking for node prefix : ok /home/jigar/local/node
Checking for libzmq : not found
'configure' finished successfully (0.072s)
Waf: Entering directory /home/jigar/local/node/lib/node_modules/zeromq/build' [1/2] cxx: binding.cc -> build/default/binding_1.o cc1plus: warnings being treated as errors ../binding.cc:745: error: "ZMQ_DEALER" redefined /usr/local/include/zmq.h:172: note: this is the location of the previous definition ../binding.cc:746: error: "ZMQ_ROUTER" redefined /usr/local/include/zmq.h:173: note: this is the location of the previous definition ../binding.cc: In static member function ‘static v8::Handle<v8::Value> zmq::Socket::GetSockOpt(const v8::Arguments&)’: ../binding.cc:343: error: ‘ZMQ_EVENTS’ was not declared in this scope ../binding.cc:345: error: ‘ZMQ_FD’ was not declared in this scope ../binding.cc:346: error: ‘ZMQ_TYPE’ was not declared in this scope ../binding.cc:347: error: ‘ZMQ_LINGER’ was not declared in this scope ../binding.cc:348: error: ‘ZMQ_RECONNECT_IVL’ was not declared in this scope ../binding.cc:349: error: ‘ZMQ_BACKLOG’ was not declared in this scope ../binding.cc: In static member function ‘static v8::Handle<v8::Value> zmq::Socket::SetSockOpt(const v8::Arguments&)’: ../binding.cc:387: error: ‘ZMQ_LINGER’ was not declared in this scope ../binding.cc:388: error: ‘ZMQ_RECONNECT_IVL’ was not declared in this scope ../binding.cc:389: error: ‘ZMQ_BACKLOG’ was not declared in this scope ../binding.cc:392: error: ‘ZMQ_EVENTS’ was not declared in this scope ../binding.cc:393: error: ‘ZMQ_FD’ was not declared in this scope ../binding.cc:394: error: ‘ZMQ_TYPE’ was not declared in this scope ../binding.cc: In function ‘void zmq::Initialize(v8::Handle<v8::Object>)’: ../binding.cc:759: error: ‘ZMQ_XREQ’ was not declared in this scope ../binding.cc:761: error: ‘ZMQ_XREP’ was not declared in this scope ../binding.cc:762: error: ‘ZMQ_DEALER’ was not declared in this scope ../binding.cc:763: error: ‘ZMQ_ROUTER’ was not declared in this scope ../binding.cc:780: error: ‘ZMQ_FD’ was not declared in this scope ../binding.cc:781: error: ‘ZMQ_EVENTS’ was not declared in this scope ../binding.cc:782: error: ‘ZMQ_TYPE’ was not declared in this scope ../binding.cc:783: error: ‘ZMQ_LINGER’ was not declared in this scope ../binding.cc:784: error: ‘ZMQ_RECONNECT_IVL’ was not declared in this scope ../binding.cc:785: error: ‘ZMQ_BACKLOG’ was not declared in this scope Waf: Leaving directory/home/jigar/local/node/lib/node_modules/zeromq/build'
Build failed: -> task failed (err #1):
{task: cxx binding.cc -> binding_1.o}
npm ERR! error installing [email protected] Error: [email protected] preinstall: node-waf clean || true; node-waf configure build
npm ERR! error installing [email protected] sh "-c" "node-waf clean || true; node-waf configure build" failed with 1
npm ERR! error installing [email protected] at ChildProcess. (/home/jigar/local/node/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected] at ChildProcess.emit (events.js:67:17)
npm ERR! error installing [email protected] at ChildProcess.onexit (child_process.js:192:12)
npm ERR! [email protected] preinstall: node-waf clean || true; node-waf configure build
npm ERR! sh "-c" "node-waf clean || true; node-waf configure build" failed with 1
npm ERR!
npm ERR! Failed at the [email protected] preinstall 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! node-waf clean || true; node-waf configure build
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!
npm ERR! System Linux 2.6.35-28-generic
npm ERR! command "node" "/home/jigar/local/node/bin/npm" "install" "zeromq" "-g"
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/jigar/npm-debug.log
npm not ok

Internally buffers regardless of high water mark settings

The following code simply increments the currentSendBacklog indefinitely

zeromq = require('zeromq');
util = require('util');

s = zeromq.createSocket('push');

// I would expect send to block after 3 messages
s['highWaterMark'] = 3
s['diskOffloadSize'] = 0

s.bind('tcp://127.0.0.1:5554', function(err) {
    if (err) throw err;

    setInterval(function() {
      s.send('test')
      util.puts("Current send backlog: " + s.currentSendBacklog())
    }, 1000)
});

I can understand the motivation not to allow send to block the event loop, however this behaviour seems counter to the design of ZMQ. Am I missing something, or is this by design?

Can't build on Ubuntu 10.10

$ sudo node-waf configure build
Setting srcdir to                        : /home/sebastianedwards/venture/node_modules/zmq 
Setting blddir to                        : /home/sebastianedwards/venture/node_modules/zmq/build 
Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : not found 
Checking for node prefix                 : ok /usr/local 
Checking for pkg-config version >= 0.0.0 : yes 
Checking for libzmq >= 2.1.0             : yes 
'configure' finished successfully (0.042s)
Waf: Entering directory `/home/sebastianedwards/venture/node_modules/zmq/build'
[1/2] cxx: binding.cc -> build/default/binding_1.o
../binding.cc: In static member function 'static v8::Handle<v8::Value> zmq::Socket::Bind(const v8::Arguments&)':
../binding.cc:443: error: invalid conversion from 'int (*)(eio_req*)' to 'void (*)(eio_req*)'
../binding.cc:443: error:   initializing argument 1 of 'eio_req* eio_custom(void (*)(eio_req*), int, int (*)(eio_req*), void*)'
Waf: Leaving directory `/home/sebastianedwards/venture/node_modules/zmq/build'
Build failed:  -> task failed (err #1): 
    {task: cxx binding.cc -> binding_1.o}

Using fresh Node v0.5.4 & ZMQ v2.1.7

zmq 2.0.0 bug [works on zmq 1.0.3]

I have a xrep server which does the bind. When 1 xreq client connects to the server it works fine. Adding one more crashes the process with this stack trace. Only happens in zmq 2.0.0. Works on zmq 1.0.3.

    [TypeError: Second argument should be an integer]
    [TypeError: Socket is closed]

    node.js:201
            throw e; // process.nextTick error, or 'error' event on first tick
                  ^
    TypeError: Cannot call method 'stop' of null
        at Socket.close (/home/shripad/CODE/AN-WORKERS/node_modules/zmq/lib/index.js:310:17)
        at Socket.<anonymous> (/home/shripad/CODE/AN-WORKERS/handle-total-monitored-sites.js:12:8)
        at Socket.emit (events.js:67:17)
        at Socket._flush (/home/shripad/CODE/AN-WORKERS/node_modules/zmq/lib/index.js:296:10)
        at Socket.send (/home/shripad/CODE/AN-WORKERS/node_modules/zmq/lib/index.js:245:8)
        at /home/shripad/CODE/AN-WORKERS/handle-total-monitored-sites.js:58:24
        at Object.callback (/home/shripad/CODE/Mongode/mongodb/lib/mongodb/collection.js:433:9)
        at Array.1 (/home/shripad/CODE/Mongode/mongodb/lib/mongodb/connection/server.js:188:36)
        at EventEmitter._tickCallback (node.js:192:40)

error: ‘malloc’ was not declared in this scope

Try to compile latest version:

root@push:/tmp/zeromq.node# node-waf build
Waf: Entering directory /tmp/zeromq.node/build' [1/2] cxx: zeromq.cc -> build/default/zeromq_1.o ../zeromq.cc: In static member function ‘static void zmq::Context::DoPoll(ev_idle*, int)’: ../zeromq.cc:109: error: ‘malloc’ was not declared in this scope Waf: Leaving directory/tmp/zeromq.node/build'
Build failed: -> task failed (err #1):
{task: cxx zeromq.cc -> zeromq_1.o}

System: Debian 5, 32bit, small EC2 instance, 2.0.8 0MQ., Node 0.2.0

Package libzmq was not found

Issue with npm install zmq.

libzmq was installed under /usr/local/lib,
/usr/local/lib/pkgconfig/libzmq.pc exists.
PKG_CONFIG_PATH sets to /usr/local/lib/pkgconfig

mac osx 10.5

npm install zeromq also could not find libzmq, but went through and everything worked.

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.