zeromq.node icon indicating copy to clipboard operation
zeromq.node copied to clipboard

ssh for zmq

Open xiutxu opened this issue 9 years ago • 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.

xiutxu avatar Jul 31 '16 22:07 xiutxu

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

ronkorving avatar Aug 01 '16 02:08 ronkorving

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)
}

reqshark avatar Aug 01 '16 06:08 reqshark