How to run Flash-Network on an external machine?

This document describes how to run the supporting application of Flash-Network project on an external machine so that any client Javascript application can connect to that AIR application. Sometimes you may want to do the installation and configuration of the separate application only once, and let all the clients connect to it from anywhere.

Please note that the original project assumes that the supporting application runs natively on the same machine, so that it can act on behalf of the local user. Running the supporting application has a security risk, because that external machine will be creating various network sockets on behalf of any client machine.

The support for external machine is implemented using a property named "airHost", which defaults to "127.0.0.1". Rest of this document explains how to use this property and how to run the AIR application on a separate host.

1. Install and run the supporting application

Download, install and run the supporting application on your server machine. You may need to install Adobe Integrated Runtime (AIR) separately if it is not already installed. Note down the IP address of this machine. Let us assume its IP address as 192.1.2.3 for the rest of this document. If your application automatically starts running after installation, close it using the right-click menu, and start it again as follows.

When your supporting application runs natively, the Flash Player client is able to launch your supporting application from within the browser. However when you wish to use the external machine for the supporting application, you need to explicitly launch it as follows.

When starting the application, you need to specify that the application should bind to "any" interface instead of only the localhost interface. You supply a command line argument named "any" to the application. For example, on Mac OS X.
  /Applications/FlashNetwork.app/Contents/MacOS/FlashNetwork any

2. Specify the API version as 1.2 and set the target IP address

The version 1.2 of the supporting application implements the support for the external machine. When embedding the Flash-Network client in your JavaScript code, use the the apiVersion as 1.2 (or higher) and specify the airHost as the IP address of your supporting application machine.
  <script type="text/javascript">
    swfobject.embedSWF("NetworkIO.swf", "flash-network", "215", "138", "10.0.0", "expressInstall.swf", {}, 
      {"allowScriptAccess": "always", "flashVars": "apiVersion=1.2&airHost=192.1.2.3&prefix=network.", "bgcolor" : "#ffffff"}, 
      {"id": "flash-network", "name": "flash-network"});
  </script>
Everything else remains the same as described in the main tutorial.

3. Change the publish and play URLs in the Realtime Gateway object

If you use the RealtimeGateway class, the publishurl and playurl properties will still use "127.0.0.1" in the host portion. You will need to change this to use the IP address of your external machine. An example is shown below.
  var gw1 = new network.RealTimeGateway();
  // wait for gw1.publishurl or gw1.playurl to be set by the supporting application.
  // Then change it, e.g., from "rtmp://127.0.0.1:1234/sip?publish=local" to "rtmp://192.1.2.3:1234/sip?publish=local"
  // and from "rtmp://127.0.0.1:1234/sip?play=remote" to "rtmp://192.1.2.3:1234/sip?play=remote"
  // Then use the modified URL with VideoIO as needed.
  var fv1 = getFlashMovie("local-video");
  fv1.setProperty("src", gw1.publishurl);

4. Save the authentication PIN

When the supporting application prompts you for authorizing the client connection, you can click on "Remember" check box, and note down the PIN number. You can then reuse the same PIN number for other clients that want to use the supporting application. You can distribute this PIN to all your users, who can use it when needed.

The authentication is specific to a web URL from which the client SWF is downloaded. If you have multiple URLs for hosting your SWF, e.g., http://myserver.com/ and http://www.myserver.com/ then there will be different authentication for these. Please make sure to use a unique URL for your SWF to avoid confusion.

You can clear the save authentication in the right click menu on the supporting application icon.

Note: The version information in the menu for the supporting application instance started with "any" argument shows an unsecure flag for your information, and to remind you about the security risks!
© 2011-2012, Intencity Cloud Technologies, LLC.