JustinTulloss/zeromq.node

ssh for zmq

Opened this issue · 2 comments

Is there a method similar to ssh from PyZMQ (http://pyzmq.readthedocs.io/en/latest/ssh.html)? If not, should I just use ssh -L 2120:localhost:2120 user@host for connecting with a publisher to a remote node?

In this particular scenario, I am attempting to connect to logstash zeromq plugin output.

Not in node-zmq. This concept is new to me, so can't say what it would take, but we accept contributions :)

the zmq_proxy() method might help here with your use case but also keep in mind:

the connections are isomorphic, it doesnt matter who does bind() or connect()

for example:

isomorphicsock(require('zmq').socket('sub'), require('zmq').socket('pub'), 5555)
isomorphicsock(require('zmq').socket('pub'), require('zmq').socket('sub'), 5556)

function isomorphicsock(s1, s2, port) {
  console.log('doing bind() and connect() ...')
  s1.bind('tcp://127.0.0.1:' + port)
  s2.connect('tcp://127.0.0.1:' + port)

  setTimeout(function(){
    if (s1.type === 'sub') {
      sub(s1)
      pub(s2, 'connected' )
    } else {
      sub(s2)
      pub(s1, 'bound' )
    }
  }, 500)
}

// work of the subscriber
function sub(s) {
  s.subscribe('')
  s.on('message', function(msg){
    console.log( String(msg) )
  })
}

// work of the publisher
function pub (s, endpoint) {
  setInterval(function(){
    s.send('hello from ' + endpoint + ' ' + s.type)
  }, 250)
}