Open noVnc from command line. (from nodeJS code)

uriel

Member
Apr 12, 2020
36
9
13
44
Hi,

I would like to make a script to connect to the display of all my proxmox VMs within a command line.

for now I can easily connect to my VMs using spice with a code like that:

Code:
const data = await api.nodes.$(this.hostname).qemu.$(realVmid).spiceproxy.$post({proxy: await this.getIP()});
const result = ["[virt-viewer]"];
for (const k of Object.keys(data)).push(`${k}=${data[k]}`);
const vvData =  result.join('\n');
// write vvData to a file, and open it with remote-viewer

But for noVnc it's a bit more complicated.

Code:
// POST a request for a NoVNC
const data = await api.nodes.$(this.hostname).qemu.$(realVmid).vncproxy.$post({websocket: false});
// the returned data contains:
// cert: string;
// password?: string;
//  port: string;
//  ticket: string;
//  upid: string;
//  user: string;

It would be nice if any common VNC client was able to connect a proxmox vnc, but I think that the Proxmox’s NoVnc, is the only one that can be used.

Is there a way to pass my login/cert information to a noVNC ?

I expect to create a local html file, append my credential in it, and to open this local file with a browser.
but I think that the noVnc wss:// connection won't work from a file://

So maybe I can start a local webserver to host this file in http://localhost:12346/…. url; and maybe add a websocket gateway to the real proxmox server...

I prefer not to over engineer this simple script...


What is the simplest solution ?

Uriel.