Connection problem noVNC (API)

gugugugu

New Member
Jun 17, 2019
4
0
1
26
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!!
 

sb-jw

Active Member
Jan 23, 2018
558
56
33
28
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.
 

gugugugu

New Member
Jun 17, 2019
4
0
1
26
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.
 

DanielWeintroub

New Member
Jan 23, 2019
1
0
1
21
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 :\\
 

gugugugu

New Member
Jun 17, 2019
4
0
1
26
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
 

sb-jw

Active Member
Jan 23, 2018
558
56
33
28
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

gugugugu

New Member
Jun 17, 2019
4
0
1
26
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.
 

haiwan

Member
Apr 23, 2019
179
0
16
32
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?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE 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 your own in 60 seconds.

Buy now!