Saleh7/ProxmoxVE_PHP_API

VNC not working

peter81745 opened this issue · 4 comments

Code:

$node = 'AoW';
$vmid = 501;
$f = Nodes::createQemuVncproxy($node, $vmid, $data = array());
$array = json_decode(json_encode($f), True);
Nodes::qemuVncwebsocket($node, $vmid, $array["data"]["port"], $array["data"]["ticket"]);
$vnc = 'https://xxx.xxx.xxx.xxx:8006/?console=kvm&novnc=1&node='.$node.'&resize=scale&vmid='.$vmid.'&path=api2/json/nodes/'.$node.'/qemu/'.$vmid.'/vncwebsocket?port=' . $array["data"]["port"] . '&vncticket=' . $array["data"]["ticket"];
echo $vnc;
echo '<iframe src="'.$vnc.'" width="1280" height="720" allowfullscreen="true"></iframe>';

it always says: Failed to connect to server

I don't think proxmox works compatible with this script anymore with new API codes.

i am using Proxmox VE 5.4 and everything works just fine except this vnc thing

same issuem i am using Proxmox VE 6

Note with this code, the Proxmox panel and Laravel panel must be under the same domain. Also, please create an isolated user for each user. If the user goes to VNC, they can access the Proxmox panel too.

public function vnc() {
        $acl = [
            'username' => 'User username',
            'password' => 'User password',
            'realm' => 'pve'
        ];

        $ticket = Access::createTicket($acl);
        $ticket = json_encode($ticket, true);
        $ticket = json_decode($ticket, true);

        setcookie('PVEAuthCookie', $ticket['data']['ticket'], 0, '/', 'PROXMOXDOMAIN', false);

        return print("<iframe width=\"100%\" height=\"100%\" frameborder=\"0\" allowfullscreen=\"\" src=\"https://PROXMOXHOSTNAME:8006/?console=kvm&novnc=1&node=NODENAMEHERE&resize=scale&vmid=VMIDHERE\"></iframe>");
}