Saturday, 14 November 2009

FMS in OSX

Hi Readers,

I would like to give you a quick description how to work with FMS (Flash Media Server) under OS-X. Unfortunately FMS server is only available for Windows and Unix. Almost. I tried to fire it up in Ubuntu 9.10, and got a bunch of error messages. I would have killed both of that bastard application. Nevermind. So these were my steps to a working environment:

1 - Install Virtualbox and Windows XP in it
This is an easy step, just make sure you use latest version of VBox.

2 - Run Windows XP, and install FMS
The development version of FMS is free: download Though, you have to have an Adobe account. (1 minutes registration) The installation is straight forward, you can't make a mistake. I suggest you using the built-in Apache if you don't use that guest os for other webserver functions.

3 - Port forward to the guest machine
I'm not a server guy, so maybe it's not the best, but it's working, and that is the point. By default, your guest OS is listening on your localhost (127.0.0.1). But without port forward you can't access to it. We have an Apache (port 80) and the FMS (admin server port: 1111, fms server port: 1935) on our newly installed Windows XP. These 3 ports we have to bind. Open a terminal in OSX, and type these commands:

(change the YOURGUESTMACHINESNAME text to the name of your guest OS - which is the name in the vbox machine list)

VBoxManage setextradata "YOURGUESTMACHINESNAME" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/httpfwd/Protocol" TCP
VBoxManage setextradata "YOURGUESTMACHINESNAME" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/httpfwd/HostPort" 8888
VBoxManage setextradata "YOURGUESTMACHINESNAME" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/httpfwd/GuestPort" 80

VBoxManage setextradata "YOURGUESTMACHINESNAME" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/fmsadmin/Protocol" TCP
VBoxManage setextradata "YOURGUESTMACHINESNAME" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/fmsadmin/HostPort" 8889
VBoxManage setextradata "YOURGUESTMACHINESNAME" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/fmsadmin/GuestPort" 1111

VBoxManage setextradata "YOURGUESTMACHINESNAME" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/fms/Protocol" TCP
VBoxManage setextradata "YOURGUESTMACHINESNAME" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/fms/HostPort" 8890
VBoxManage setextradata "YOURGUESTMACHINESNAME" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/fms/GuestPort" 1935

(more about these settings in the virtualbox's UserManual.pdf)

Now you have to restart your guest OS. Settings above allows you to access to your guest OS, for example for port 80 type http://localhost:8888 into your browser in OS-X. You should see the FMS server start page with a video (train). If you don't see, there is something I missed or is wrong.
And one more step, you have to turn of the firewall in Windows. (Sorry but I haven't found a better way.)

4 - Create a sample Flash / Flex project on the client side (host OS)

It doesn't really matter which one you use. Here you are my working actionscript code:

public var nc:NetConnection = new NetConnection();

public function connect():void {
var r:Responder = new Responder(responderResult, responderStatus);

nc.connect('rtmp://localhost:8890/HelloWorld');
nc.call('serverHelloMsg', r, "John Doe");
}

public function responderResult(result:Object):void {
trace('Result came: ' + result.toString());
}

public function responderStatus(status:Object):void {
trace('Status update');
}

5 - create the server side code (in the guest OS)

The server side parts has to be written in ActionScript 1.0. (Pretty weird.) I just pasted the sample from the tutorial:

application.onConnect = function(client) {

client.serverHelloMsg = function(text) {
return "Welcome: " + text;
}

application.acceptConnection(client);

}

Copy it into: C:\Program Files\Adobe\Flash Media Server 3.5\applications\HelloWorld\HelloWorld.asc.

6 - Start FMS server in the guest OS
In Start Menu you can find an icon that starts the FMS server.

7 - Test you application
And be patient if it won't work at the first try.

Of course, these stuffs are all available in the documentations.
Flash Media Server: get all the official documentations
Great FMS service tool for your host OS: FMS Feature Explorer

Best wishes,
Peter

No comments:

Post a Comment