I want to display VM console created by vsphere in browser.So I use the html5 console sdk.
Here is the sdk https://code.vmware.com/samples/1117/showing-web-console-of-a-vm-via-vsphere-html-console-sdk#.
Here is the sdk document https://code.vmware.com/docs/9197/html-console-sdk-programming-guide/GUID-632AC4ED-3292-4901-8CFC-1FAC4C37DA37.html
I use the second method. The webmksTicket method. But it show some error.
Here is my code:
<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Console</title>
</head>
<body>
<h1>This is a sample of showing Web Console of a VM in vCenter 6.0.</h1>
<link rel="stylesheet" type="text/css" href="./css/wmks-all.css" />
<script type="text/javascript" src="./jquery-3.5.0.min.js"></script>
<script type="text/javascript" src="./jquery-ui.min.js"></script>
<script type="text/javascript" src="./wmks.min.js"></script>
<div id="wmksContainer" style="position:absolute;width:100%;height:100%"></div>
<script>
var wmks = WMKS.createWMKS("wmksContainer",{})
.register(WMKS.CONST.Events.CONNECTION_STATE_CHANGE, function(event,data){
if(data.state == WMKS.CONST.ConnectionState.CONNECTED){
console.log("connection state change : connected");}
});
wmks.connect("wss://ESXi_IP:443/ticket/d9c3b2f517ba1685");
</script>
</body>
</html>
Here is my error in browser console:
wmks.min.js:1 WebSocket connection to 'wss://ESXi_IP:443/ticket/d9c3b2f517ba1685' failed: Error during WebSocket handshake: Unexpected response code: 503
telnet ESXi_ip 443 is fine
This webmksTicket number is obtained according to the tutorial in this sdk document.It should be correct.
I'm using vsphere 6.7. I open the html by nginx1.16.1 I use the html5 console sdk 2.1.0
Can anyone tell me what should I do. Or is there any other way for me to display the virtual machine console in the browser.