4

I am working with the node.js example. I have installed openpgm and zeromq 3.2 on my ubuntu 12.10 machine. Here's the code:

var zmq = require('zmq')
  , port = 'epgm://eth0;239.192.1.1:5555';

  var socket = zmq.socket('pub');

  socket.identity = 'publisher' + process.pid;

  var stocks = ['AAPL', 'GOOG', 'YHOO', 'MSFT', 'INTC'];

  socket.bind(port, function(err) {
    if (err) throw err;
    console.log('bound!');

    setInterval(function() {
      var symbol = stocks[Math.floor(Math.random()*stocks.length)]
        , value = Math.random()*1000;

      console.log(socket.identity + ': sent ' + symbol + ' ' + value);
      socket.send(symbol + ' ' + value);
    }, 1000);
  });

and the other app:

var zmq = require('zmq') , port = 'epgm://eth0;239.192.1.1:5555';

var socket = zmq.socket('sub');

socket.identity = 'subscriber' + process.pid;

socket.connect(port);

socket.subscribe('AAPL'); socket.subscribe('GOOG');

console.log('connected!');

socket.on('message', function(data) { console.log(socket.identity + ': received data ' + data.toString()); });

I am not sure if I am using the correct multicast addressing. I have tried these apps together in the same machine, and also in another machine in the network. I am pretty sure I have not thought through that part, but I can't seem to find any good explanation about it anywhere. But I expected this to work on the same machine anyway. Any ideas?

PS: Forgot to explain what exactly happens: Basically the push program just pushes all the messages without any error, and the pull program starts but doesn't receive any message.

Harald K
  • 26,314
  • 7
  • 65
  • 111
Munim
  • 6,310
  • 2
  • 35
  • 44

2 Answers2

2

epgm and pgm work only for PUB/SUB.

Pieter Hintjens
  • 6,599
  • 1
  • 24
  • 29
  • @Wildfire Oh. I hadn't realized that my title said push/pull. Sorry! – Munim Mar 25 '13 at 17:12
  • ... and only on different machines. [3.0 NEWS](https://raw.githubusercontent.com/zeromq/zeromq3-x/master/NEWS): `MQ_MCAST_LOOP removed. There's no support for multicast over loopback any more. Use IPC or TCP isntead.` – rustyx Oct 07 '15 at 07:08
2

Not sure if this helps, but I've been experimenting with zmq in node as well and have made some observations:

I am running using four machines: 1: OS X 10.8.3 2: Ubuntu 12.10 in VM (bridged) 3: Ubuntu 12.04 separate machine
4: Ubuntu 12.04 separate machine

When I start the same test server on all machines (not too dissimilar from your code above) Machine 1: sees updates from machine 3 and 4 Machine 2: sees updates from 1, 2, 3, and 4 Machine 3: sees updates from 1, 3, 4 Machine 4: sees updates from 1, 3, 4

so it seems like OS X blocks broadcasts to itself. Ubuntu 12.10 in the VM is getting everyone's but having problems sending (possibly related to running in the VM?) and the other machines are getting their own.

My server/client:

os = require 'os'
zmq = require 'zmq'

client = zmq.socket "sub"
server = zmq.socket "pub"

client.connect "epgm://224.0.0.1:5555", (error) ->
    if error?
        console.log "client error:", error

client.subscribe ""
client.on "message", (buffer) ->
    console.log "received ping:", buffer.toString!

server.bind "epgm://224.0.0.1:5555", (error) ->
    if error?
        console.log "server error:", error
    setInterval ( -> 
        server.send "#{os.hostname!}" 
    ), 1000

process.on "SIGINIT", ->
    client.close!
    server.close!
    process.exit!
Cyclone
  • 2,103
  • 1
  • 14
  • 13
  • So basically, the OSX machine is blocking broadcasts. I am not even running ubuntu in a virtual machine. It is a base OS, and I still can't see my own updates. But I will try your code (particularly the broadcast address you have chosen) and give it a shot – Munim Mar 26 '13 at 05:19
  • Actually on further investigation... OS X is working correctly... It's using a newer version of libzmq than ubuntu, and they blocked loopback on multicast because it had problems. So the OS X machine is getting everyone else's broadcasts but its own. It's broadcasting fine. The one that seems to be having problems is 12.10. The 12.04 machines are also working properly given they are using v2 of zmq rather than v3. – Cyclone Mar 26 '13 at 15:50