No Ticket issue

Dec 3, 2018
30
0
6
34
Germany
squote.de
Godd Day,

i have testing the Web noVNC. I get only 401 no Ticket. I hope anyone can help me to fix it.


Code:
<head>
        <title>Proxmox Console</title>
        <meta charset="utf-8">
    </head>

<?php

require("./pve2_api.class.php");
$hostname = "myhostname";
$username ="API";
$password ="mypassword";
$vmid ="999999996";



$pve2 = new PVE2_API("$hostname", "$username", "pam", "$password");
?>
<html>
<head>
     <title>noVNC extern test</title>
</head>
<body>

<?php

if (!empty($pve2)) {


    if ($pve2->login())
    {
        $pve2->setCookie();
        foreach ($pve2->get_node_list() as $node_name) {
         // print_r($pve2->get("/nodes/".$node_name."/status"));
//echo("$node_name");

// specifing on what node vm exists

if ($node_name == "vhost1") {
echo "<pre>";
echo "vncproxy POST\n";
$vncproxy = $pve2->post("/nodes/vhost1/qemu/999999996/vncproxy", array("websocket" => 1));
$vncproxy['ticket'] = urlencode($vncproxy['ticket']);
$vncwebsocket = $pve2->get("/nodes/vhost1/qemu/999999996/vncwebsocket?port={$vncproxy['port']}&vncticket={$vncproxy['ticket']}" , array('port' => $vncproxy['port'], 'vncticket' => $vncproxy['ticket']));

print_r ($vncproxy);


$new_vncwebsocket = array();
$new_vncwebsocket['port'] = $vncproxy['port'];
$new_vncwebsocket['vncticket'] = $vncproxy['ticket'];



//$vncwebsocket = $pve2->get("/nodes/vhost1/qemu/".$vmid."/vncwebsocket", $new_vncwebsocket);

    //print_r ($vncwebsocket);

?>
<script>
PVE_vnc_console_event = function(appletid, action, err) {
}
</script>


<applet id='22222' border='true' code='com.tigervnc.vncviewer.VncViewer' archive='http://example.com/VncViewer.jar' width='150%' height='300%' style='width: 1024px; height: 706px; '>
<param name='id' value='22222'>
<param name='PVECert' value='<?php echo str_replace("\n", '|', $vncproxy["cert"]); ?>'>
<param name='HOST' value='<?php echo $hostname; ?>'>
<param name='PORT' value='<?php echo $vncproxy["port"]; ?>'>
<param name='USERNAME' value='<?php echo $vncproxy["user"]; ?>'>
<param name='password' value='<?php echo $vncproxy["ticket"]; ?>'>
<param name='Show Controls' value='Yes'>
<param name='Offer Relogin' value='Yes'>
</applet>
<?php

echo "\n";
echo "<iframe height='500px' width='1024px' src='https://vhost1.squote.de:8006/?console=kvm&novnc=1&vmid=999999996&vmname=intern.web.sQuote.de&node=vhost1&resize=off&name=".$vncproxy["user"]."&vncticket=".base64_encode($vncproxy["ticket"])."'></iframe>\n";
}






        }
    } else {
        print("Login to Proxmox Host failed.\n");
        exit;
    }
} else {
    print("Could not create PVE2_API object.\n");
    exit;
}
?>
 

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!