[Help]connect to local listener(localhost) via RDP to implement ssh tunnel via javascript on Windows 8 metro RRS feed

  • Question

  • How can I make a rdp connection to ssh-tunnel on localhost (I have a local listener on a specific port, and we should let RDP to connect to local listener successfully firstly)?

    I always get the following error "Your computer could not connect to another console session on the remote computer because you already have a console session in progress".

    The codes I used are as below, and if the address is localhost or, the error will be popped up. So how can I handle it? Thanks.

    (function () {

    "use strict";

    var appViewState = Windows.UI.ViewManagement.ApplicationViewState;

    var ui = WinJS.UI;

    ui.Pages.define("/pages/rdpWindow.html", {

    rdpax_clsid: "CLSID:EAB16C5D-EED1-4E95-868B-0FBA1B42C092",

    rdpClient: {},

    rdpClientSettings: {},


    * Function called during page initialization.


    * @param element[in] DOM element containing all elements in the page

    * @param options[in] contains actionObj, which was sent by JSCDK


    ready: function (element, options) {

    var content = options.actionObj.content,

    // address = content.address,

    address = "",

    port = content.port,

    // address = "localhost",

    username = content["user-name"],

    password = content.password,

    domain = content["domain-name"],

    windowWidth = $(window).width(),

    windowHeight = $(window).height(),

    parentObject = document.getElementById("rdpParent");

    console.log("address:" + address);

    console.log("port:" + port);


    * Even if we set our page's body style in the css to not have a background,

    * it will be overridden by default.html's style. As a result, we must clear

    * our background manually here.


    setImmediate(function () {

    document.body.style.backgroundImage = "none";

    document.body.style.backgroundColor = "#000000";


    // Create the ActiveX control that will be used to load the RDP session.

    this.rdpClient = document.createElement("object");

    this.rdpClient.id = document.uniqueID;


    try {

    // Load the RDP ActiveX control.

    this.rdpClient.className = "ActiveX";

    this.rdpClient.classid = this.rdpax_clsid;

    this.rdpClient.width = windowWidth;

    this.rdpClient.height = windowHeight;

    this.rdpClientSettings = this.rdpClient.settings;

    // Initialize a bunch of settings.

    this.rdpClientSettings.setRdpProperty("authentication level", 0);

    this.rdpClientSettings.setRdpProperty("desktopheight", windowHeight);

    this.rdpClientSettings.setRdpProperty("desktopwidth", windowWidth);

    this.rdpClientSettings.setRdpProperty("domain", domain);

    this.rdpClientSettings.setRdpProperty("enablecredsspsupport", false);

    this.rdpClientSettings.setRdpProperty("full address", address);

    this.rdpClientSettings.setRdpProperty("gatewayusagemethod", 0);

    this.rdpClientSettings.setRdpProperty("prompt for credentials", false);

    this.rdpClientSettings.setRdpProperty("username", username);


    * XXX "EncryptedPassword" may be the key to us sending the password through

    * for SSO but I don't know how it should be encrypted. Sending it in

    * plaintext throws an exception, so I'm commenting it out for now. -- grossag


    //this.rdpClientSettings.setRdpProperty("EncryptedPassword", password);

    // Undocumented flag to not show the certificate warning dialog.

    this.rdpClientSettings.setRdpProperty("ShowPublisherWarningDialog", false);


    * Handle desktop disconnection by showing an error message, if one exists,

    * then refreshing the desktop list and going there.


    this.rdpClient.attachEvent("OnDisconnected", function (reason, extendedReason, errorMessage) {

    mainUIController.checkShowErrorMessage(errorMessage, function () {





    } catch (e) {

    e = e;




    * Function called in response to viewState changes to update page layout.


    * @param element[in] DOM element containing all elements in the page

    * @param viewState[in] new view state

    * @param lastViewState[in] previous view state


    updateLayout: function (element, viewState, lastViewState) {

    // XXX TODO: Update layout.




    No pains, no gains.

    Monday, October 15, 2012 8:47 AM


All replies

  • Hi Vincent,

    You cannot make connections to localhost.  This is blocked by the network isolation restrictions and is by design.

    You can test with a localhost connection, however your application will be rejected by the store certification process.  Set this article for more info:



    Jeff Sanders (MSFT)

    Monday, October 15, 2012 2:44 PM
  • To be clear, this is only for communication within the same app container.  One component inside of the app registers on loopback and another component connects to it.  People from Microsoft had previously confirmed that this is acceptable here so let me know if that has changed.  I do think that Vincent got this working; the key was just to make sure to explicitly connect on the specific loopback port that the component had registered a listener on.
    Thursday, October 18, 2012 1:00 AM
  • That is correct.  You can communicate as long is you are in the same container.

    Jeff Sanders (MSFT)

    • Proposed as answer by Adam Gross Wednesday, November 7, 2012 5:45 PM
    Thursday, October 18, 2012 12:33 PM