VMware vCloud

 View Only
Expand all | Collapse all

VMware HTML Console SDK

  • 1.  VMware HTML Console SDK

    Posted Dec 18, 2015 04:41 PM

     

    Hello.  We are trying to create a custom solution to launch VMs for our own homegrown Hands on Labs project.  We would like to display a page with available labs and that once clicked on, will launch a VM inside a browser window.

     

    We have got things working with our old approach but we have to utilize ActiveX with a RDP client on the webpage but this is of course limited to just the Internet Explorer browser.  We are trying to use the new HTML Console SDK to open this up to multiple browsers.

     

    We have been trying to create a new solution using the VMware HTML Console SDK with this documentation: https://www.vmware.com/support/developer/html-console/html-console-sdk-100-programmer-guide.pdf

     

    Current Environment:

    VMware vCloud Director: 5.5.5.3153714

     

    We are trying to construct the WebSocket URL so we can run the wmks.Connect method.  Can anyone explain this part of the documentation from page 6:  “<ws | wss> :// <host:port>/ <path> /? <authentication info>”    Where do the parts come from to build this URL?  Our main issue right now is to first get the connection setup. 

     

    If you have any further insight into how this needs to be setup at the most basic level, or have any further documentation/examples that can help us out, it would be greatly appreciated.



  • 2.  RE: VMware HTML Console SDK

    Posted Jan 14, 2016 01:30 PM

    I also encountered this problem. You have already decided it?



  • 3.  RE: VMware HTML Console SDK

    Posted Jan 14, 2016 04:14 PM

    Unfortunately, I am still having trouble with this.  I have not been able to find any further examples online or anymore SDK information.  I have been looking into getting the actual SDK Customer Support from VMware since it seems I am hitting a wall with all that I currently have.

    I don't know how to fully construct the WebSocket URL or where all the pieces needed for that come from. 



  • 4.  RE: VMware HTML Console SDK

    Posted Feb 09, 2016 04:01 PM

    Hi guys,

    you have to query POST /vApp/{id}/screen/action/acquireMksTicket vCloud API operation. That will answer you a MksTicket like this:

    <MksTicket xmlns="http://www.vmware.com/vcloud/v1.5">

        <Host> xs:string </Host>

        <Vmx> xs:string </Vmx>

        <Ticket> xs:string </Ticket>

        <Port> xs:int </Port>

    </MksTicket>

    The URL is in the form:

    wss://host/port;ticket

    Use Vmx content when creating the wmks var in js:

    var wmks = WMKS.createWMKS("wmksContainer",

    {

    enableUint8Utf8: true,

    VCDProxyHandshakeVmxPath: "VMX_GOES_HERE",

    });

    Hope it helps.



  • 5.  RE: VMware HTML Console SDK

    Posted Feb 22, 2016 04:21 PM

    If you are using Python and libcloud to access vCloud Director 5.5, I've recently added support for MksAcquireTicket in the vCloud driver:

    Added method to access the console of a running VM. · apache/libcloud@da6fac8 · GitHub



  • 6.  RE: VMware HTML Console SDK

    Posted Feb 25, 2016 06:43 PM

    Thank you everyone for the continued help with this!

    I have a much better understanding of what is needed to build the WebSocket now.

    I am having some issues now and I think it might be with the version of JQuery that I am using.

    Per the SDK Documentation here: https://www.vmware.com/support/developer/html-console/html-console-sdk-100-programmer-guide.pdf

    I am using version 1.8.3 of JQuery and version 1.8.16 of JQuery UI.

    I am getting these errors now (In the 'wmks.js' file):

    This line is bringing back NULLs:

    My 'Immediate Window' shows them as NULL, which is blowing up the rest of the code:

    I am calling the 'createWMKS' function on my .aspx page like this:

    I tried the most recent version of JQuery but that didn't help.  Any notes on this issue would be greatly appreciated.

    Thanks again.



  • 7.  RE: VMware HTML Console SDK

    Posted Feb 26, 2016 08:58 AM

    Hello,

    Yes, I had the same problem. First I'm using the latest jquey js without problem. The problem here is that the example is horrible:

    <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.1.8.16.min.js"></script>

    <script type="text/javascript" src="wmks.js" type="text/javascript"></script>

    <script>

    var wmks = WMKS.createWMKS("wmksContainer",{})

    .register(WMKS.CONST.Events.CONNECTION_STATE_CHANGE, function(event,data){

    if(data.state == cons.ConnectionState.CONNECTED)

    {

    console.log("connection state change : connected");

    }

    });

    wmks.connect(“ws://127.0.0.1:8080”);

    </script >

    <div id=”wmksContainer” style=”position:absolute;width:100%;height:100%”></div>

    WRONG!!!!!!!

    The core is trying to create the canvas into the <div id=”wmksContainer” style=”position:absolute;width:100%;height:100%”></div> but when the script is being processed this div hasn't been created yet so...

    you have to move the div before  the script like this:


    <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.1.8.16.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 == cons.ConnectionState.CONNECTED)

    {

    console.log("connection state change : connected");

    }

    });

    wmks.connect(“ws://127.0.0.1:8080”);

    </script >

    GOOOD!!!!

    Now you are going to have another error with cons "if(data.state == cons.ConnectionState.CONNECTED)" cons doesn't exist.... great... so you can erase all the if or you can change cons.ConnectionState.CONNECTED  to WMKS.CONST.ConnectionState.CONNECTED

    I hope this helps!!!

    Good luck!!!



  • 8.  RE: VMware HTML Console SDK

    Posted Feb 26, 2016 02:21 PM

    Thank you so much for the reply!  This was the issue I was having.  Glad to see I wasn't alone in thinking that the documentation is lacking...

    I'll keep this post open and running while I continue to work on this project.



  • 9.  RE: VMware HTML Console SDK

    Posted Feb 29, 2016 10:07 AM

    Yup, documentation is a little bit scarce...

    Right now my HTML template code looks like this (the {{ variables }} are being filled by the web framework I'm using).

                    <link rel="stylesheet" type="text/css" href="https://communities.vmware.com/static/css/wmks-all.css" />

                    <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>

                    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.16/jquery-ui.min.js"></script>

                    <script type="text/javascript" src="/static/js/wmks.js" type="text/javascript"></script>

                    <a href="javascript:void(wmks.sendKeyCodes([17,18,46]))">send Ctrl+Alt+Del</a>

                    //

                    <a onClick="goFullScreen()" href="#">go full screen</a>

                    //

                    <a href="javascript:void(disconnect())">disconnect</a>

                    //

                    <a href="javascript:void(wkms.showKeyboard())">show keyboard</a>

                    //

                    <a href="javascript:void(wkms.hideKeyboard())">hide keyboard</a>

                    <div id="wmksContainer" style="position:absolute; width:800px; height:600px;"/>

                    <script>

                        function goFullScreen() {

                            wmks.enterFullScreen();

                            wmks.setRemoteScreenSize(screen.height, screen.height);

                            wmks.updateScreen();

                        }

                        function disconnect() {

                            wmks.disconnect();

                            wmks.destroy();

                        }

                    </script>

                    <script>

                        var wmks = WMKS.createWMKS("wmksContainer",

                                {

                                    enableUint8Utf8: true,

                                    {#                                changeResolution: false,#}

                                    {#                                enableVVC: false,#}

                                    VCDProxyHandshakeVmxPath: "{{ vmx }}",

                                });

                        console.log(wmks.getConnectionState());

                        wmks.register(WMKS.CONST.Events.CONNECTION_STATE_CHANGE,

                                function(event,data){

                                    if(data.state == WMKS.CONST.ConnectionState.CONNECTED){

                                        console.log("connection state change : connected");

                                    }

                                }

                        );

                        wmks.register(WMKS.CONST.Events.ERROR,

                                function(event,data){

                                    console.log("PLAF");

                                }

                        );

                        wmks.connect("{{ vmware_link }}");

                        console.log(wmks.getConnectionState());

                        window.onbeforeunload = function(){

                            wmks.disconnect();

                        };

                    </script >

    It's working more or less OK, although Windows is not changing it's resolution when going full screen. Also, the mobile devices are not showing the keyboard when pressing the link...

    Cheers.



  • 10.  RE: VMware HTML Console SDK

    Posted Mar 22, 2016 11:33 AM

    wmks.connect (link ), could anyone please let me know how should i construct link for VM on host (which is not managed by vCenter).



  • 11.  RE: VMware HTML Console SDK

    Posted Mar 23, 2016 05:02 PM

    I'm trying to use something like this but doesn't work:

    wss://vcenter.vc.local:9443/vsphere-client/webconsole.html?vmId=vm-1233&vmName=MYSERVER&serverGuid=19513155-7a26-4ff1-89cd-27

    e2d6249bc5&host=vcenter.vc.local&sessionTicket=cst-VCT-522bb7ec-d037-e023-6183-8592aae67679--tp-62-20-25-DC-E8-29-82-77-25-E0-87-23

    -45-70-C2-71-A8-F8-ED-9F&thumbprint=5A:AB:D4:75:29:E8:D5:94:09:8F:D2:91:CF:DC:AB:C0:69:03:37:42



  • 12.  RE: VMware HTML Console SDK

    Posted May 23, 2016 11:32 PM

    juanfont, any chance you could give us some sample code for generating your URL? I can get a ticket fine and I have all other details A-Okay, but there's a lot of conflicting information in this thread and the documentation is pretty vague about what to do. You seem to know what you're doing, so any information you could provide would be a big help.

    Cheers in advance.



  • 13.  RE: VMware HTML Console SDK

    Posted Mar 23, 2016 03:08 PM

    Hello,

    I'm trying to use your sample to connect to the vCenter console, do you use ws://127.0.0.1:8080 or a vcenter link ?

    Are you using vSphere 5.x or 6.x ?

    Thanks

    Vittorio



  • 14.  RE: VMware HTML Console SDK

    Posted Feb 22, 2016 04:17 PM

    Hello, after some research we have found the following about the url:

    (wss|ws)://host:port/console/authd?vmId=vm-number&vmName=name&host=hostwithoutport&sessionTicket=sessionticket&thumbprint=thumbprint

    So everything in red you have to change, if you choose wss the port is 7343 and ws 7341 (I'm not 100% sure I always use wss).


    How to get the sessionTicket well with Java using Yavijava GitHub - yavijava/yavijava: Yet Another vijava. A fork of vijava http://sourceforge.net/p/vijava/


    ServiceInstance si = new ServiceInstance(new URL(host), user, password, true);

          si.getServerConnection();

         

          String ticket =si.getSessionManager().acquireCloneTicket();

            

          System.out.println("ticket=" + ticket);

          Thread.sleep(30*60*1000);

         

          si.getServerConnection().logout();

    OR

    Here there is a Pearl code

    How to generate a pre-authenticated HTML5 VM console link in vSphere 5.5 that works on all OSes! | virtuallyGhetto

    And if you don't have the thumbprint it is the last part of the ticket --tp-THUMBPRINT

    I hope this helps.

    Greetings!



  • 15.  RE: VMware HTML Console SDK

    Posted Apr 25, 2016 10:07 AM

    This works perfect. In vSphere 6.0 , the url is like "wss://vcenter_server_ip:9443/vsphere-client/webconsole/authd?..."



  • 16.  RE: VMware HTML Console SDK

    Posted May 20, 2016 09:02 AM

    I use the link like "wss://vcenter_server_ip:9443/vsphere-client/webconsole/authd?..." in vsphere 6.0,,but it doesn't work. The link that "wss://vcenter_server_ip:9443/vsphere-client/webconsole.html?.." is right?



  • 17.  RE: VMware HTML Console SDK

    Posted May 20, 2016 09:25 AM

    webconsole.html is the web page for displaying VM Web Console by vSphere Web Client. The javascript in webconsole.html will use "wss://vcenter_server_ip:9443/vsphere-client/webconsole/authd?..." to connect to vCenter Server.

    What error you got in the web browser when connecting "wss://.../authd?..." ?



  • 18.  RE: VMware HTML Console SDK

    Posted May 20, 2016 10:50 AM

    link created:

    wss://192.168.3.128:9443/vsphere-client/webconsole/authd?vmId=vm-205&amp;vmName=zs999&amp;host=vcenter.yunhorn.com&amp;sessionTicket=cst-VCT-5241dab7-1e0e-845f-be81-3d83f5a8b5a4--tp-AF-B5-66-D0-BA-4A-CF-A9-8E-73-50-8B-B1-62-D4-8D-7A-BD-0E-B8&amp;thumbprint=AF:B5:66:D0:BA:4A:CF:A9:8E:73:50:8B:B1:62:D4:8D:7A:BD:0E:B8


    console error info:

    failed: WebSocket opening handshake was canceled

    ps:

    telnet 192.168.3.128 9443 is fine




  • 19.  RE: VMware HTML Console SDK

    Posted May 24, 2016 09:44 AM

    The code should be like this:

        var url = "wss://192.168.3.128:9443/vsphere-client/webconsole/authd?vmId=vm-205&vmName=zs999&host=192.168.3.128&sessionTicket=cst-VCT-5241dab7-1e0e-845f-be81-3d83f5a8b5a4--tp-AF-B5-66-D0-BA-4A-CF-A9-8E-73-50-8B-B1-62-D4-8D-7A-BD-0E-B8";
        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(url);
    

    Note:

    1) The value of sessionTicket can be acquired by visiting "https://192.168.3.128/mob/?moid=SessionManager&method=acquireCloneTicket"

    2) Make sure before opening the html page containing the javascript code above, use your web browser to visit "https://192.168.3.128:9443/vsphere-client/" once and accept the SSL certificate (no need to login vSphere Web Client).



  • 20.  RE: VMware HTML Console SDK

    Posted May 31, 2016 06:34 AM

    url:

    wss://192.168.3.128:9443/vsphere-client/webconsole/authd/?vmId=vm-312&vmName=tableTest&amp;host=192.168.3.128&sessionTicket=cst-VCT-52f9d70d-52ec-f4ab-47ba-cf8c2db9f2e0--tp-AF-B5-66-D0-BA-4A-CF-A9-8E-73-50-8B-B1-62-D4-8D-7A-BD-0E-B8

    console output:

    failed: Error during WebSocket handshake: Unexpected response code: 500

    anyway,thank you for you replay.



  • 21.  RE: VMware HTML Console SDK

    Posted May 31, 2016 06:45 AM



  • 22.  RE: VMware HTML Console SDK

    Posted Mar 24, 2016 03:00 PM

    I have created a WebSocket URL but I keep getting this error message when I try feeding it into the wmks.connect() method:

    WebSocket Error: Network Error 12029, A connection with the server could not be established

    I have created this WebSocket URL:

    wss://srv-sdesx0.onbase.net:7343/console/authd?vmId=vm-4211&vmName=IS-SPLAB0&host=https://srv-sdesx0.onbase.net&sessionTicket=527a6c6a-547d-e72b-7c8b-2f0eda6354f0&thumbprint=0D:EF:0A:77:B0:18:BA:1D:F8:C5:45:3E:99:FC:5A:F9:57:AC:7B:A9

    Does that look correct to you guys?  Am I missing something?



  • 23.  RE: VMware HTML Console SDK

    Posted Mar 29, 2016 08:55 AM

    The wss URL was wrong, you just need to use ESX host/port and a WebMKS Ticket

    Example

    wss://192.168.8.121:443/ticket/63de9452ffafa5f7

    More details on my blog Vittorio Pavesi: vSphere 6 HTML Console



  • 24.  RE: VMware HTML Console SDK

    Posted Mar 31, 2016 02:26 PM

    Hello, and thanks for replying.

    I created this WebSocket URL here: wss://srv-sdesx0.onbase.net:443/ticket/af00f07ec71267f2

    I am now getting this error message: WebSocket Error: Network Error 12045, The certificate authority is invalid or incorrect

    Any ideas what I am missing now?



  • 25.  RE: VMware HTML Console SDK

    Posted Mar 31, 2016 02:43 PM

    Try to connect from your browser to https://srv-sdesx0.onbase.net:443 and accept certificate, then try again.


    If it doesn't work, try to install the vCenter certificate in the web server providing the HTML pages



  • 26.  RE: VMware HTML Console SDK

    Posted Jul 12, 2016 06:15 PM

    OK so now we have the certificate installed correctly on the server.  We have SSL configured.

    I am now getting these errors:

    and

    Can you explain what port I should be using and what the differences are?  Not sure what we are missing at this point.  Thanks for the help.



  • 27.  RE: VMware HTML Console SDK

    Posted Sep 19, 2016 07:13 PM

    Not sure if you're still experiencing issues, but I've recently embarked upon the HTML5 console journey and happened across this thread. From your first image, it looks like you're using the wrong type of ticket in the URL, but then in your second image, it looks like you have the correct ticket, but you should try including the port with the host, like:

    wss://srv-sdesx2.onbase.net:443/ticket/{ticket_string}

    Actually, the AcquireTicket page should tell you what port to use.

    The problem I'm having with all of this is that the wmks approach only seems to work with ESXhost IPs, and I am trying to expose the console to external parties, so ESXhost IPs are pointless. I investigated another method, whereby I emulate the URL that vSphere Web Client generates for the built-in web console, which are in the format:

    https://{host}:9443/vsphere-client/webconsole.html?vmId={vm_moId}&vmName={vm_name}&serverGuid={server_guid}&locale=en_US&host={host}:443&sessionTicket={AcquireCloneTicket_output}&thumbprint={ssl_thumbprint_from_sessionTicket}

    However, as of vSphere 6.0, it seems that the Single Sign On (SSO) page is forced in between, so while I am able to craft the URL perfectly, once you click on the link the SSO page jumps in front and you must login to get to the web console.

    If anyone knows of another approach, I'd be much appreciated.



  • 28.  RE: VMware HTML Console SDK

    Posted Dec 09, 2016 09:42 AM

    Hi sleeyuen,

    Since we started testing with vSphere 6 we ran into the exact same problem. Your approach works perfectly in vSphere 5.5, but fails in vSphere 6, redirecting to the SSO-Page.

    Have you found a solution yet? Or a workaround of some kind?

    Regards,

    Stephan



  • 29.  RE: VMware HTML Console SDK

    Posted Apr 25, 2016 10:53 AM

    I have verified this solution. It works great.