Install wowza media server on Amazon EC2 and S3

UPDATE from OliverNote: Elastifox does not work in current versions of FF, no matter what trickery is employed. You can easily achieve the main goals in this tutorial via the AWS Management Console.


For this tutorial, we’re going to assume that you have Firefox and ElasticFox installed and that you already have an AWS account set up and that you have setup your amazon account to work with Wowza (if you need to do that, it’s easy.  Just follow this link).  We’re also assuming that you have some knowledge of AWS and it’s inner workings, but you don’t have to be an expert – i.e. you should probably know the difference between an instance and a bucket.

Open up your ElasticFox add-on by clicking on Tools > ElasticFox.

Set up your account credentials using your email you login with for the account name.

For your access key and secret access key, go to http://aws.amazon.com and click on the “Account” tab and then click on “Security Credentials.”  You can find these two fields in there.  You will also need these fields later when we set up our AWS instance to communicate with the S3 bucket.

Elasticfox credential window

You can confirm your access by clicking the ‘Availability Zones’ tab.  If something comes up, sweet bro, you’re connected.  Otherwise, close and restart Firefox and Elasticfox. This is sometimes necessary the first time you enter new credentials. If that STILL doesn’t work, check your credentials and try again.

Now we need to set up KeyPairs for the instances. To do this, click on the ‘KeyPairs’ tab, then on the Green, ‘Create a KeyPair’ button.  You’ll then get prompted to name your key pair. Name it and then save the .pem file to your machine.

Next you will need to get the most current AMI id from wowza.  You can find the most appropriate AMI ID for your region and desired instance size. You can find a list of these ids here http://www.wowzamedia.com/forums/content.php?203.  The Wowza Server AMI includes the Fedora Core 8 operating system, Java 6 JDK along with the Wowza Server.

Now, you need to spool up a new Wowza instance.  Take that previous AMI ID, click on the ‘Images’ tab in ElasticFox and enter the AMI ID.  You should see only one instance now.  Click on it and select the ‘Launch Instance’ button.  The default values with your key pair should be set so all you need to do now is click the ‘Launch’ button at the bottom of the prompt.

here’s what that launch button looks like.

You’ll now get taken to the ‘Instances’ tab where you can see all of the instances you’ve got with AWS including your brand new Wowza instance. The state of your new instance will be listed as ‘Pending.’  If it’s not there, don’t worry, it should be listed there shortly.

Now we need to open up port 1935 for the wowza server to allow streaming. To do this, click on the ‘Security Groups’ tab, select the default group on the left and click on the ‘Grant permission’ button above the right pane.  Select HTTP from the ‘Protocol Details’ drop down, ‘TCP/IP’ from the protocol dropdown, and enter port 1935 in the port field.  That’s the default port for streaming flash, but you can change this if you would like, but I’m not going to go into detail about that here.  Leave the ‘Host’ radio button selected and enter ’0.0.0.0/0′  in the field to open the port to any new AMIs.

When your instance’s state turns to ‘running’ it is ready for testing.  To test, you should grab the wowza Simple video streaming example files if you’ve got the server installed locally.  On Win7, that’s located in C:\Program Files\Wowza Media Systems\Wowza Media Server 2.2.3\examples\SimpleVideoStreaming.  If you don’t have that installed locally, you can just grab these files.  Open up simplevideostreaming.html and enter the public dns for your instance and the name of a test stream that is already on the server.  You can get the public domain by right-clicking on the instance in ElasticFox and selecting ‘Copy Public DNS Name to Clipboard.’

Server: rtmp://[instance-public-domain]/vod
Stream: merry_melodies_falling_hare

Click ‘Play’ and you should see some bugs bunny on screen.

You should also open up port 22 and ssh to the server.  I’m not going to go into detail on how to do that here as you can find that pretty easily all over the google.  You can do this directly from ElasticFox by right-clicking and selecting ‘Connect to Instance.’  That should walk you through connecting if you haven’t done it before.

When you ssh into the server, you can now stop, start, and restart the Wowza media server with the following commands.

service WowzaMediaServer stop

service WowzaMediaServer start

service WowzaMediaServer restart

If you’re on AWS, you will probably also want to start using S3.  By default an S3 application is already installed on your instance.  To start using it, just change the application name in your Server string to vods3, so the server would become

‘rtmp://[instance-public-domain]/vods3′

Then your stream name becomes

[file-type]:amazons3/[bucket-name]/[path-to-video]/[file-name]

The file-type by default is flv, but you can set it to mp4 for all the quicktime formats that flash/wowza supports or mp3 for audio.

Now you’ll probably want to go ahead and set up some security.  To make it so your Wowza instance can access private videos in your S3 bucket, add your AWS secret key and AWS key to the Server.xml and restart Wowza. The Server.xml should be located in

/home/wowza/conf/Server.xml

Add the keys to the Root > Server > Properties > Property nodes.

If you can read, it should be pretty self explanatory when you’re in there.

You should also set it up to use the secureToken module. To do this edit the vods3 application xml

/home/wowza/conf/vods3/Application.xml

and add the following node to the module node to the Root > Application > Modules node

<Module>
<Name>ModuleSecureToken</Name>
<Description>ModuleSecureToken</Description>
<Class>com.wowza.wms.plugin.security.ModuleSecureToken</Class>
</Module>

Then add the following property nodes to the Root > Application > Properties node

<Property>
<Name>secureTokenSharedSecret</Name>
<Value>[Your-secret]</Value>
</Property>
<Property>
<Name>requireSecureConnection</Name>
<Value>true</Value>
<Type>Boolean</Type>
</Property>

Set your secret token in the first node to something secret.  Remember that secret token, because you’ll need to add it to your flash video player.

Restart wowza for your changes to take effect.  Now you’ll need to update your flash video player to send and use the token.  Grab the example that wowza provides for you from here: Media Security Example

Basically, you need to send an encrypted version of that shared secret on your netConnection object.  You need to encrypt it using the TEA class available in the download.  For AS3, your call on the netconnection object will look like this.

var netConnection:NetConnection = new NetConnection();
netConnection.addEventListener(NetStatusEvent.NET_STATUS, onNCStatus);
netConnection.connect("rtmpe://amazon-public-dns/vods3");

 

 

    private function onNCStatus(e:NetStatusEvent):void {
trace("nc.onStatus: " + e.info.code + " (" + e.info.description + ")");
switch(e.info.code) {
case "NetConnection.Connect.Success":
if (e.info.secureToken != undefined) {
//<--- SecureToken change here - respond with decoded secureToken
var secureResult:Object = new Object();
secureResult.onResult = function(isSuccessful:Boolean) {
trace("secureTokenResponse: " + isSuccessful);
}
netConnection.call("secureTokenResponse", new Responder(secureResult.onResult), TEA.decrypt(e.info.secureToken, sharedSecret)); }
onNetConnectionSuccess();
break;
case "NetConnection.Connect.Failed":
trace(e.info.description);
break;
case "NetConnection.Connect.Rejected":
trace(e.info.description);
break;
}
}

For a detailed guide about the security add ons check out this guide: Wowza Media Server Media Security Users Guide.

For a more detailed guide to setting EC2 and S3 up, check out wowza’s comprehensive guide here.

Also, once you’ve got everything ready for production, you should check out this forum post to make sure to fine tune your server. http://www.wowzamedia.com/forums/content.php?5-general-tuning

Comments

    Jason |

    How are you running elasticfox? I have ffox 4.0.1 and it doesn’t work.

    Caleb |

    You have to enable the menu bar by right clicking the bookmark bar and selecting the menubar, and then go to Tools > ElasticFox. I don’t see a short cut for it.

    Oliver |

    Best Wowza EC2 Tutorial yet.

    Note: Elastifox does not work in current versions of FF, no matter what trickery is employed.

    You can easily achieve the main goals in this tutorial via the AWS Management Console.

    Caleb |

    Thanks for the feedback Oliver. It’s nice to know someone’s found it helpful!

    I’ll update the post with your comment!