vSphere 6 HTML Console

If you want to provide an HTML console for vSphere 6 you can just follow these simple steps:









  1. Download ZIP from VMware Site https://www.vmware.com/support/developer/html-console/  (HTML, JS, CSS)
  2. Install the vCenter Certificate into the web server providing HTML console (REALLY IMPORTANT)
  3. Create an HTML page with the following 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> <link rel="stylesheet" type="text/css" href="wmks-all.css" /> 
<script type="text/javascript" src="jquery-1.8.3.min.js"></script> 
<script type="text/javascript" src="jquery-ui.min.js"></script> 
<script type="text/javascript" src="wmks.js" type="text/javascript"></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://ESXhost:443/ticket/TICKETNUMBER"); 
</script > 
</body> 
</html>

In order to generate ticket you can use something like this:
Add-PSSnapin VMware.VimAutomation.Core
$VCenter = "vcenter.vc.local"
Connect-VIServer $VCenter -User vc\administrator -Password Password
$Vm = Get-VM VIRTUALMACHINE1
$Ticket = $Vm.ExtensionData.AcquireTicket("webmks")
$ESXHost = $Ticket.host
$TicketNumber = $Ticket.ticket


The logic is:

More details here: https://www.vmware.com/support/developer/html-console/html-console-sdk-100-programmer-guide.pdf


Tags: , , ,

About author

Vittorio Pavesi

28comments

  1. Anonymous
    4:48 PM

    This is not helpful at all. The WebSocket URL is incorrect.

  2. The WebSocket URL wss://ESXhost:443/ticket/TICKETNUMBER is correct, what is your issue ?

  3. Anonymous
    3:29 PM

    Do you have any documentation you can link me to that shows how to construct the WebSocket URL like the one you created above?

  4. Unfortunately I haven't, it's really simple, see this example:

    wss://ESXhost:443/ticket/TICKETNUMBER

    ESXHOST is the IP/NAME of the Host where the VM is located
    443 is the port of the Host where the VM is located
    TICKETNUMBER is the ticket obtained from AcquireTicket("webmks") method

  5. I have verified this solution. It works great. The WebMKS ticket can be generated on https://vcenter_ip/mob/?moid=vm-XXX&method=acquireTicket

  6. I verified this solution. It works!

  7. Anonymous
    4:37 PM

    Your buddy backs up your claim.

  8. console output:

    WebSocket connection to 'wss://192.168.3.114/ticket/524225e3-544f-de90-bba7-54b04de47e43'
    failed: WebSocket opening handshake was canceled

    what happen?

  9. Can you try to set the port ?

    'wss://192.168.3.114:443/ticket/524225e3-544f-de90-bba7-54b04de47e43'

    Moreover, can you try to open the connection using browser ?

    https://192.168.3.114:443/ticket/

    Or telenet 192.168.3.114 443

  10. "WebSocket connection to 'wss://192.168.3.114/ticket/524225e3-544f-de90-bba7-54b04de47e43'
    failed: WebSocket opening handshake was canceled"

    I have solve this problem after install vCenter Certificate. but a new problem has arisen

    console output :

    wmks.min.js:1 2016-05-20T03:49:26.088Z [Warn ] relativepad : RELATIVEPAD
    wmks.min.js:1 2016-05-20T03:49:26.104Z [Info ] Not a touch device, and hence skip touch handler
    wmks.min.js:1 WebSocket connection to 'wss://192.168.3.114:443/ticket/52c2c395-c661-8f43-110b-b95b03d5780a' failed: Error during WebSocket handshake: Unexpected response code: 503

    telnet 192.168.3.114 443 is fine

    https://192.168.3.114:443/ticket/ output:
    503 Service Unavailable (Error connecting tunnel on named pipe: (null))

    Give me some advice, thank you very much!

  11. I think it's something related to certificate, try to import the certificate to the machine where you have the console files.

  12. Anonymous
    3:25 PM

    I've tried connecting using the wmks plugin but am getting a connection timed out WebSocket connection to 'wss:///ticket/4305cf38b7fe11de' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT

    using the host grabbed from the webmks ticket and port 443. Is this possibly a cert error?

  13. You wrote: wss:///ticket/4305cf38b7fe11de but should be wss://ESXHOST/ticket/4305cf38b7fe11de, seems that you forgot to specify host

  14. Anonymous
    5:46 PM

    To Shun Zhong
    I've received the Error during WebSocket handshake: Unexpected response code: 503 with wrong ticket number, try to generate new one

  15. Anonymous
    12:40 AM

    To Shun Zhong and other having that problem. The cause is likely that your using the wrong ticket type.
    The webmks ticket type is about 16 characters long, the one you've got in your example looks like a standard mks ticket type which is about 32 characters.
    If your doing it through the mob use the AcquireTicket method on the vm object and use the parameter 'webmks' as the ticket type. The webmks ticket type only exists on vcenter 6 that I can see.

  16. Anonymous
    9:14 AM

    how can I install the vCenter Certificate?

  17. First you must obtain the certificate file, you have 2 way:
    1) search into your vcenter all files with *.cer
    2) open you browser to https://vcenter, then export the certificate (e.g. https://support.mozilla.org/en-US/questions/1076086)

    Then install it using MMC Certificate (e.g. http://helpdesk.ssls.com/hc/en-us/articles/204333681-How-to-import-intermediate-and-root-certificates-via-MMC)

  18. Anonymous
    1:45 AM

    I get the following error
    failed: Error during WebSocket handshake: Unexpected response code: 404
    my url is wss://esxhost:443/ticket/

    I did not do the certificate installation part. I am not sure how to do it I have my html file on my Mac as a local file. Please help

  19. I'm sorry but I really don't know how to install certificates on Mac...

  20. Anonymous
    2:46 AM

    So, I tried the steps to install certificate using mmc as u mentioned on windows and used the same html that is given here.
    I get the following error now
    failed: WebSocket opening handshake was canceled ( I am not sure if this still is certificate issue).

  21. Anonymous
    6:54 AM

    i have a question that how to get the certificate? I do not know where the .cer file locate, can i get it form vsphere client?

  22. You can get it using the browser or if you've access to vcenter, you can get it from the installation folder (es. C:\program files...)

  23. Remote console works on some ESXi host and fails on some ESXi host. Is there any configuration needed to get it working?
    Looks like server security types/authentication scheme is not matching (See console log below). What changes are needed to get it working?


    --- console output where it’s not working on some ESXi hosts----
    wmks.min.js:1 2016-11-03T05:24:53.466Z [Info ] Not a touch device, and hence skip touch handler
    wmks.min.js:1 2016-11-03T05:24:54.089Z [Info ] WebSocket HAS binary support
    wmks.min.js:1 2016-11-03T05:24:54.090Z [Info ] WebSocket created protocol: binary
    wmks.min.js:1 2016-11-03T05:24:54.101Z [Info ] Server security types: 2
    wmks.min.js:1 2016-11-03T05:24:54.101Z [Info ] Using authentication scheme: 2
    wmks.min.js:1 2016-11-03T05:24:54.101Z [Info ] vnc authentication not implemented



    --- console output where its working ----
    wmks.min.js:1 2016-11-03T05:26:59.000Z [Warn ] relativepad : RELATIVEPAD
    wmks.min.js:1 2016-11-03T05:26:59.014Z [Info ] Not a touch device, and hence skip touch handler
    wmks.min.js:1 2016-11-03T05:26:59.593Z [Info ] WebSocket HAS binary support
    wmks.min.js:1 2016-11-03T05:26:59.595Z [Info ] WebSocket created protocol: binary
    wmks.min.js:1 2016-11-03T05:26:59.604Z [Info ] Server security types: 1
    wmks.min.js:1 2016-11-03T05:26:59.604Z [Info ] Using authentication scheme: 1
    -----

    Thanks

  24. Anonymous
    9:53 AM

    I can get access to vm html5 console using wmks.connect before installed certificate using mmc to Os in which of client I used browser to access console.
    But it neets me doing lots of work to install certificate to each client Os in which I used browser to access.perhaps if I have hundreds of client to access the vm console, will I have to install certificate to each client?
    Is there any way to install certificate in more easy way?

  25. The certificate must be installed into the web server not on the client

  26. Anonymous
    8:22 PM
    This comment has been removed by a blog administrator.
  27. Hello Vittorio,

    I have been attempting to use the Vmware HTML console work in my lab. I'm using the example from the Vmware download page and using the wss format that you advised (wss://IP:PORT/ticket/TICKET_NUMBER). When I load the page in my browser, I am receiving a Javascript error: WebSocket Error: Network Error 12045, The certificate authority is invalid or incorrect.

    You had mentioned in step 2 that you imported the certificates from VCenter. I have tried importing the certificates from my ESXI server into Internet Explorer by navigating to the page and manually adding the certificate. However, I continue to see this error.

    My environment is using just ESXI 6.5 without a VCenter installation. Do you happen to know if VCenter is required in order to make the HTML console work? Or can this be done by connecting directly the ESXI server? At this point I'm just having issues with the certs and thought perhaps my lack of Vcenter may have something to do with it. Thanks for your time.

    Cheers

  28. Hello Jon, I tested it with vcenter (it's required to provide ticket) and vsphere 6.0
    Let me know if you find a solution

Post a Comment