Opening a VNC console from an external app

utf8x

New Member
Jul 14, 2023
2
0
1
I'm developing a customer facing admin panel application that talks to Proxmox in the background and I need to be able to open a noVNC window from there. Through various tutorials and forum posts, I was able to put together a URL that should open the console however it always ends with a 401: No Ticket error.

https://<pve-ip>:8006/?console=kvm&novnc=1&node=hetz&resize=1&vmid=101&path=api2/json/nodes/<nodename>/qemu/101/vncwebsocket/port/5900/vncticket/PVEVNC%3a64B15391[...]

This is the C# code I'm using to generate that URL (using this library: https://github.com/Corsinvest/cv4pve-api-dotnet)

Code:
var vnc = await _client.Nodes[node].Qemu[vmid].Vncproxy.Vncproxy();
var dic = vnc.ResponseToDictionary;
var data = dic["data"] as IDictionary<string, object>;
var ticket = HttpUtility.UrlEncode(data["ticket"] as string);
var port = int.Parse(data["port"] as string);

await _client.Nodes[node].Qemu[vmid].Vncwebsocket.Vncwebsocket(port, ticket);

var sb = new StringBuilder();
sb.Append("https://<pve-ip>:8006/");
sb.Append("?console=kvm&novnc=1");
sb.Append($"&node={node}");
sb.Append("&resize=1");
sb.Append($"&vmid={vmid}");
sb.Append($"&path=api2/json/nodes/{node}/qemu/{vmid}/vncwebsocket/port/{port}/vncticket/{ticket}");

return sb.ToString();

Any idea what I'm doing wrong?
 
I moved the thread to the Proxmox VE forum - since it seems PVE related...

the 401 no ticket error tells you that you need to authenticate first - see the wiki-page on how to use the API:
https://pve.proxmox.com/wiki/Proxmox_VE_API

I hope this helps!
 
Oh, sorry if I put it in the wrong forum.

As far as authentication goes, I thought the whole point of retrieving a ticket from the API and passing it to the VNC console was being able to launch the console without being authenticated to PVE proper?
 
Oh, sorry if I put it in the wrong forum.

As far as authentication goes, I thought the whole point of retrieving a ticket from the API and passing it to the VNC console was being able to launch the console without being authenticated to PVE proper?
regardless of how you login it's always via the API.

have use asked the api for a ticket?
https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu/{vmid}/vncproxy
https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu/{vmid}/vncwebsocket

my advice it get it working with curl 1st so you know then you know what and how you need to pass info
 
Last edited:
I'm developing a customer facing admin panel application that talks to Proxmox in the background and I need to be able to open a noVNC window from there. Through various tutorials and forum posts, I was able to put together a URL that should open the console however it always ends with a 401: No Ticket error.

https://<pve-ip>:8006/?console=kvm&novnc=1&node=hetz&resize=1&vmid=101&path=api2/json/nodes/<nodename>/qemu/101/vncwebsocket/port/5900/vncticket/PVEVNC%3a64B15391[...]

This is the C# code I'm using to generate that URL (using this library: https://github.com/Corsinvest/cv4pve-api-dotnet)

Code:
var vnc = await _client.Nodes[node].Qemu[vmid].Vncproxy.Vncproxy();
var dic = vnc.ResponseToDictionary;
var data = dic["data"] as IDictionary<string, object>;
var ticket = HttpUtility.UrlEncode(data["ticket"] as string);
var port = int.Parse(data["port"] as string);

await _client.Nodes[node].Qemu[vmid].Vncwebsocket.Vncwebsocket(port, ticket);

var sb = new StringBuilder();
sb.Append("https://<pve-ip>:8006/");
sb.Append("?console=kvm&novnc=1");
sb.Append($"&node={node}");
sb.Append("&resize=1");
sb.Append($"&vmid={vmid}");
sb.Append($"&path=api2/json/nodes/{node}/qemu/{vmid}/vncwebsocket/port/{port}/vncticket/{ticket}");

return sb.ToString();

Any idea what I'm doing wrong?
using vnc is more complex. Request project support
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!