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"> 
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Console</title> 
<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 > 

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
$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

Share on Google Plus

About Vittorio Pavesi

    Blogger Comment
    Facebook Comment


Anonymous said...

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

Vittorio Pavesi said...

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

Anonymous said...

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

Vittorio Pavesi said...

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


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

Hui Hu said...

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

Hui Hu said...

I verified this solution. It works!

Anonymous said...

Your buddy backs up your claim.

Shun Zhong said...

console output:

WebSocket connection to 'wss://'
failed: WebSocket opening handshake was canceled

what happen?

Vittorio Pavesi said...

Can you try to set the port ?


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

Or telenet 443

Shun Zhong said...

"WebSocket connection to 'wss://'
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://' failed: Error during WebSocket handshake: Unexpected response code: 503

telnet 443 is fine output:
503 Service Unavailable (Error connecting tunnel on named pipe: (null))

Give me some advice, thank you very much!

Vittorio Pavesi said...

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

Anonymous said...

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?

Vittorio Pavesi said...

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

Anonymous said...

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

Anonymous said...

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.

Anonymous said...

how can I install the vCenter Certificate?

Vittorio Pavesi said...

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)

Anonymous said...

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

Vittorio Pavesi said...

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

Anonymous said...

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).

Anonymous said...

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?

Vittorio Pavesi said...

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...)

Thiyagarajan Ramasamy said...

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


Anonymous said...

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?

Vittorio Pavesi said...

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

Anonymous said...
This comment has been removed by a blog administrator.
Jon Dub said...

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.


Vittorio Pavesi said...

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

Neil Baillie said...

When I use mob to get the ticket "webmks" the page shows the ticket as "not shown" after submit all other fields do show. I'm using 6.5 vcenter.

Vittorio Pavesi said...

Hello Neil, I'm using vcenter 6.0 and I have never tested it on 6.5

fdo said...

Hi Vittorio, I am trying to test this solution and I am struggling. I am connecting to a vSphere 6.0.

What I've got so far:
- working of a windows 7 and windows 2012 VM
- downloaded latest VMware HTML Console SDK Release 2.1. extracted content to local directory
- downloaded all the js/css (jquery and jquery.ui) file to a directory.
- create console.html made sure script src is pointing to right location
- used the powershell script to generate ticket and wss url.
- I insert that new wss url into the html file
- installed the ESXI certificate on the local machine
When i launch the html file i just get the text and blank page. There is no error messages.
I've how should i troubleshoot this? Any insight would be greatly appreciated...

fdo said...

I resolved my own issues. There was some serious formatting issue when i copy and pasted the code to my editor. Thanks..

Moviepedia said...

Hi vittorio, my application is in java, how to get Ticket or call AcquireTicket in java ?