node-websockify icon indicating copy to clipboard operation
node-websockify copied to clipboard

how to handle the situation of multiple target?

Open lvbirui opened this issue 4 years ago • 3 comments

is there any way to connect multiple target VNC server by this package?

lvbirui avatar Jan 20 '21 03:01 lvbirui

Each listener would need a dedicated port but multiple instances of websockify could be created within one node instance.

I haven't tested this at all, but something like this should work


var websockify = require('@maximegris/node-websockify');
var vncServers = [
  {
    ip:'192.168.0.2',
    vncPort: 5901,
    nodePort: 5901
  },
  {
    ip:'192.168.0.2',
    vncPort: 5901,
    nodePort: 5902
  }
]

var vncWebsockifies = []

for (var i = 0; i < vncServers.length; i++) {
  vncWebsockifies[i] = websockify({
  source: '127.0.0.1:' + vncServers[i].nodePort,
  target: vncServers[i].ip + ':' + vncServers[i].vncPort,
  web : './directory',
  cert: 'certSSL',
  key: 'certSSL-key'
  });
}

Craigzyc avatar Jan 20 '21 12:01 Craigzyc

Each listener would need a dedicated port but multiple instances of websockify could be created within one node instance.

I haven't tested this at all, but something like this should work


var websockify = require('@maximegris/node-websockify');
var vncServers = [
  {
    ip:'192.168.0.2',
    vncPort: 5901,
    nodePort: 5901
  },
  {
    ip:'192.168.0.2',
    vncPort: 5901,
    nodePort: 5902
  }
]

var vncWebsockifies = []

for (var i = 0; i < vncServers.length; i++) {
  vncWebsockifies[i] = websockify({
  source: '127.0.0.1:' + vncServers[i].nodePort,
  target: vncServers[i].ip + ':' + vncServers[i].vncPort,
  web : './directory',
  cert: 'certSSL',
  key: 'certSSL-key'
  });
}

It kindly wrong , i had tested. websokify is just one object,can not handle two adress.

lvbirui avatar Jan 21 '21 09:01 lvbirui

@lvbirui See the answer in the other similar issue. You are correct. You actually need to do a require for each instance by the looks of it

Craigzyc avatar Jul 12 '21 14:07 Craigzyc