Connection problem noVNC (API)

gugugugu

New Member
Jun 17, 2019
4
0
1
31
Hello,
I'm trying to run noVNC using php. I use the call: api2/json/nodes/pve/qemu/{id}/vncwebsocket
before this, I call the login api,and vnticket api to get cookie、 the vncticket and the port.

finally,I got the request like this,upload_2019-6-17_22-26-17.png

and with nginx proxy
upload_2019-6-17_22-27-28.png

the upstream is right.
as i think everything vill be ok,but the error 502 break me down.
maybe someone can help me solve this problem. And forgive my poor english, thanks!!
 
Do you want to use the noVNC Console (like clicking in the GUI) or VNC Client (eg Tight NC) ? You are mixing here two different things. The vncwebsocket isn't needed to use the noVNC Console.
 
Do you want to use the noVNC Console (like clicking in the GUI) or VNC Client (eg Tight NC) ? You are mixing here two different things. The vncwebsocket isn't needed to use the noVNC Console.
yes, I want to use the noVNC Console in my html, maybe I should learn more about proxmox. I attach the proxmox only 2 days ago.
In the PVE GUI ,when I open a console,the vncwebsocket is connected.
And I just imitate the actions what the PVE GUI console do.
As you say, maybe my thinking is wrong. Is there any issue can provide me to learn.
 
yes, I want to use the noVNC Console in my html, maybe I should learn more about proxmox. I attach the proxmox only 2 days ago.
In the PVE GUI ,when I open a console,the vncwebsocket is connected.
And I just imitate the actions what the PVE GUI console do.
As you say, maybe my thinking is wrong. Is there any issue can provide me to learn.

Hello, I am working around this "problem" for a several months :D
But... this is not a problem. Yeah, API have vncproxy and vncwebsocket methods, but they are for internal use only.
It's still not possible to external vnc into VM of your proxmox server without patching proxmox source files.

If you have a lot of free time, you can read my last answer from this issue on github: github.com/ZzAntares/ProxmoxVE/issues/17
and try to debug problem in my patch,because in practice it works differently than in theory :\\
 
Hello, I am working around this "problem" for a several months :D
But... this is not a problem. Yeah, API have vncproxy and vncwebsocket methods, but they are for internal use only.
It's still not possible to external vnc into VM of your proxmox server without patching proxmox source files.

If you have a lot of free time, you can read my last answer from this issue on github: github.com/ZzAntares/ProxmoxVE/issues/17
and try to debug problem in my patch,because in practice it works differently than in theory :\\

well,I have solved the problem with the novnc console successfully show in my html.
The error I posted before was because a letter.
i missed the https with http when i rewrite the nginx's configuration which named proxy_pass.
If you think the case is useful for you, you can mail me with jialeiting@huanqiu.com
 
Here a working example for PHP
PHP:
//Get Ticket from PVE API
$novnc_ticket = $proxmox->create('/access/ticket', array('username' => '<USER_NAME>@pve', 'password' => '<USER_PASSWORD>'))['data'];

//Create Cookie "PVEAuthCookie"
setrawcookie("PVEAuthCookie", urlencode($novnc_ticket['ticket']), time()+3600, "/", ".domain.tld", 1, 1);

//Generate Link to get access to noVNC Console from external
$novnc_link = 'https://proxy.domain.tld/?console=kvm&novnc=1&resize=off&vmid=<VMID>&node=<NODE>&UserName=<USER_NAME>@pve&CSRFPreventionToken='.urlencode($novnc_ticket['CSRFPreventionToken']).'&oticket='.urlencode($novnc_ticket['ticket']);

You can change the "?console" to"lxc" instead of "KVM" and the "&novnc" to "xtermjs". For xtermjs AFAIK you need to connect to the origin Node, at noVNC Console its not related, maybe this is fixing now.
 
  • Like
Reactions: hitman
Here a working example for PHP
PHP:
//Get Ticket from PVE API
$novnc_ticket = $proxmox->create('/access/ticket', array('username' => '<USER_NAME>@pve', 'password' => '<USER_PASSWORD>'))['data'];

//Create Cookie "PVEAuthCookie"
setrawcookie("PVEAuthCookie", urlencode($novnc_ticket['ticket']), time()+3600, "/", ".domain.tld", 1, 1);

//Generate Link to get access to noVNC Console from external
$novnc_link = 'https://proxy.domain.tld/?console=kvm&novnc=1&resize=off&vmid=<VMID>&node=<NODE>&UserName=<USER_NAME>@pve&CSRFPreventionToken='.urlencode($novnc_ticket['CSRFPreventionToken']).'&oticket='.urlencode($novnc_ticket['ticket']);

You can change the "?console" to"lxc" instead of "KVM" and the "&novnc" to "xtermjs". For xtermjs AFAIK you need to connect to the origin Node, at noVNC Console its not related, maybe this is fixing now.


thank you, but I have solved my problem.
I just use another api to connect the vncwebsocket,
and then show the console in html with a novnc javascript library.
it works well.
 
thank you, but I have solved my problem.
I just use another api to connect the vncwebsocket,
and then show the console in html with a novnc javascript library.
it works well.
hi gugugugu
you use which api?
have wish share me?
 
Can anybody help me to solve me noVNC problem.
I got Error 401: no ticket
 

Attachments

  • Screenshot 2023-11-06 124907.png
    Screenshot 2023-11-06 124907.png
    97 KB · Views: 21
Is there any documentation on how to connect to a virtual machine console using API and noVNC? Please share it.
The steps I followed are as follows:

  1. Send a request to /api2/json/access/ticket.Response: CSRFPreventionToken | ticket
  2. Then send a request to /api2/json/nodes/<NODE_NAME>/qemu/<VM-ID>/vncproxy.Response: Port | vnc Ticket
I passed these details into HTML like this:
wss://proxmox_ip:8006/api2/json/nodes/<NODE_NAME>/qemu/<VM-ID>/vncwebsocket?port=<vncproxy-port>&vncticket=<vncproxy-ticket>


However, it's not working. I also tried this method:
<iframe src="https://proxmox-ip:8006/?console=kvm&novnc=1&vmid=<VM-ID>&node=<NODE_NAME>">

But it gives a "401 not ticket" error.
Please help me!
 
Is there any documentation on how to connect to a virtual machine console using API and noVNC? Please share it.
The steps I followed are as follows:

  1. Send a request to /api2/json/access/ticket.Response: CSRFPreventionToken | ticket
  2. Then send a request to /api2/json/nodes/<NODE_NAME>/qemu/<VM-ID>/vncproxy.Response: Port | vnc Ticket
I passed these details into HTML like this:
wss://proxmox_ip:8006/api2/json/nodes/<NODE_NAME>/qemu/<VM-ID>/vncwebsocket?port=<vncproxy-port>&vncticket=<vncproxy-ticket>


However, it's not working. I also tried this method:
<iframe src="https://proxmox-ip:8006/?console=kvm&novnc=1&vmid=<VM-ID>&node=<NODE_NAME>">

But it gives a "401 not ticket" error.
Please help me!
Check this script: https://github.com/Blub/pve-manager/blob/master/spice-example-sh
 
I am getting a 401 error. I followed the instructions based on this link and encountered two issues.

https://forum.proxmox.com/threads/401permission-denied-invalid-pvevnc-ticket.110961/

First issue: The validity of each ticket is 40 seconds.

Second issue: How can I view the console of a virtual machine through the API?

I have several users who should not have access to Proxmox, and I want them to be able to view their virtual machine's console through a ticket!

In ESXi, it is done like this:

wmks.connect("wss://192.168.1.93:443/ticket/d2cd15c632b18599");
 

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!