At a glance Main Projects Tutorials Resume

Poll

If you got lost using this tutorial, at what point was it?
Before installing subversion
After installing subversion
I followed everything but am having other problems


Red5 Media Server Development Setup Tutorial


This tutorial was written in November, 2008 and covers one way of setting up the Red5 Flash Media Server in a Windows development environment. The intended audience is users that are familiar with Red5 and are interested in developing a custom application. If you just want to test red5, dont follow this tutorial. Instead grab one of the official releases at: http://www.osflash.org/red5

Software Tools

1. Java SE Development Kit (JDK): http://java.sun.com/javase/downloads/index.jsp
2. Apache Ant: http://ant.apache.org/
3. Subversion: http://subversion.tigris.org/
4. Adobe Flash Player: http://www.adobe.com/products/flashplayer/

Before We Start:

Over a year ago I started working with Red5 which ultimately caused me to have to learn Flash development as well. If you are new to Red5 and new to Flash, its possible you will find this tutorial extremely frustrating as I probably would have a year ago. Your best bet of getting started with red5 is the flashextensions video tutorials. I understand that all the acronyms that come along with Java and flash are frustrating when trying to learn. Just stick with it, and you'll be a proffessional before you know it.

Step 1 - Install The Java Development Kit

A screencapture of the JDK download site
Red5 runs and is built on Java, the first step of setting up a development environment is getting the latest Java Development Kit. Java is notorious for using confusing acronyms in their product names. Currently the Java Development Kit goes by Java SE Development Kit. Just look for the download that contains the words “Development Kit” You can install the Java Development Kit (JDK) wherever you want, but you will need to know the exact path to the installation folder in later steps. I had an old version of the JDK on my computer, so I un-installed it and started with the newest version.

Step 2 - Set Windows Environment Variables for Java

A screencapture showing the pannel used to edit environment variables
After you have installed the JDK, the first thing to do is edit your Windows environment variables. Regardless if using Linux or Windows, the JAVA_HOME environment variable always needs to be set in order to ensure that other applications can see that java is installed. In all versions of Windows that I am familiar with , Environment Variables can be accessed via accessing the "My Computer" or "Computer" properties, then going to the "Advanced" tab / pannel. It should be noted that I am using Windows XP as a reference. Once in the Environment Variables dialog box, under the "System variables" list, click on the "New" button. For "Variable Name" put in JAVA_HOME. For "Variable Value" put in the exact OS specific path to the installation directory of the Java JDK. As an example, I made my Variable value: G:\java\jdk1.6.0_10

Step 3 - Install Apache Ant

The Apache Ant download page
This is the question I asked when I first had to use this tool. Apache Ant is a build tool for Java applications. It basically allows several java applications to be compiled at once. Its like a Windows batch script or a C++ makefile. The method of development with Red5 that I am showing uses Apache Ant in order to build the server and its associated applications using only one command and a build script.
When you go to the Ant website, get the .zip version of Ant and simply unzip it to a place on your hard drive. Just like the JDK, you need to know the exact path to Ant and specifically its bin directory.

Step 4 - Set Windows Environment Variables for Ant

Setting the ANT_HOME windows environment variable
Just like Java, Ant also requires Environment Variables to be set in order to ensure proper operation. Ant requires two variables. Just like Java, under the System variables section in Environment Variables, you should create a New variable. This time give it the Variable name "ANT_HOME" and a value of the directory it is installed (unzipped) in.

Setting the Path environment variable for apache ant
The second modification for ant is to add its bin directory to the "Path" System variable. If you scroll down under the "System variables" section you will see a variable named "Path" click on it and click "Edit". For Variable value, you will see several operating system directory paths separated by semicolons. You need to add the path to ants bin folder to this list.

For example, an exerpt from my Path Variable values reads:
C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\QuickTime\QTSystem\;
To add Ant to it, I would modify it to look like:
C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\QuickTime\QTSystem\;G:\java\apache-ant-1.7.1\bin;
In my case, Ant's bin directory is located at: G:\java\apache-ant-1.7.1\bin

Step 5 - Test Ant and Java at the Command Line

Testing java and ant using the command line
In order to make sure that we have installed the Java JDK and Ant correctly, open a command prompt window by going to start, run, and type cmd.
In the command prompt window first type "java" and you should see a whole bunch of usage parameters get listed. This means Java is installed correctly.
The next thing to type is "ant". You should see some dialog like "build.xml does not exist". This means ant is installed properly as well.
If for some reason, the java or ant commands aren't responding properly it probably means that you made an error while configuring the Environment Variables.

Step 6 - Install Subversion (SVN)

What is Subversion?
Subversion is a code version tool that allows multiple programmers to work on a project at the same time. Typically whoever is in charge of the project looks over the various code versions, the commits the best version to the "trunk" or main version of the application. If you see people talking about the Red5 "trunk", it means it is the main working version of the code.
We need subversion installed in order to get the latest main working version of the Red5 code. If you get a binary version of subversion that doesn't have an installer, make sure to add it to your Environment Variables so that it can be accessed from the command line.
There are various ways of getting subversion and I am not going to cover them in this tutorial, I hope not to your detriment.

Step 7 - Get the Trunk of Red5 from the Google Code Repository

Using SVN to get the latest red5 trunk from googlecode
Assuming that you have subversion installed; create a directory, that you want all the code from Red5 to go into. Open up the Windows command prompt; start, run, cmd. And change directories to the folder you just created. Also open up an Internet browser and navigate to the googlecode Red5 project page. (As of 2008, Red5's source is housed using googlecode)
Under the "Source" tab on the googlecode page, you'll find the subversion command line command to "checkout" or get the source code of the latest trunk of Red5. Reverberating the command on the googlecode page:
svn checkout http://red5.googlecode.com/svn/java/server/trunk/ red5-read-only

When you run the command, you should see a list of files scroll down the screen as they are downloaded. You'll also notice the folder you ran the above command in start to become populated with files and directories.

Step 8 - Try to compile and run Red5 using Ant

The red5 build script using ivy to download dependencies from googlecode
Assuming all of the previous steps have worked, you are first entitled to a bit of congratulations. Now we get to move onto the fun stuff.
Open a command prompt and change directories to the folder that you just used svn to download all of the code into. You should see in the base red5 directory a file called "build.xml". This is the Ant build script for compiling Red5.
In order to compile the server, make sure your command prompt is at the location of the same directory that build.xml is located in. Simply run the command:
ant server

and you will see the build process start. You should see a large list of Google dependencies scroll by, some of which may be downloaded on the spot. During this process you may get firewall prompts from Java. Allow exceptions in your firewall. If all goes well you will continue to see things fly by in the console window until all the output stops and the last prompt will read. "Startup done in ", then it lists the milliseconds. As long as you leave this command prompt window open, Red5 will be running.

Step 9 - Test and Run Red5

The default red5 webpage that will run on localhost when compiling using ant
Assuming Red5 has started correctly, open an internet browser again and type in:





http://localhost:5080/

You should be presented with a Red5 webpage which has various links. If this doesnt work, we can still run the tests directly from their folders which I will explain shortly. A little ways down the page, you will see a message that says "Most of the demos must be installed first, click here to select the demos you want to install". This is different from the past, as the demos used to always come bundled with the code. In any case, click on the link to open the installer. If you didnt get anything when trying the localhost link mentioned above and you are certain red5 has compiled and is running, the swf for the demo application installer is located in: red5 code directory/webapps/installer

Step 10 - Install a Demo Application For Further Testing

The Red5 installer application that is used to downlod the example applications
When the installer first opens, just click on "Connect". The installer should connect and list all of the demo applications available. I would suggest that you install oflaDemo by simply highlighting its name and clicking Install. After the installation, if you look in the red5 install folder/webapps/ you should notice that a new folder "oflaDemo" has been created. The webapps folder is where all of the source code for Red5 applications is placed. When we run the ant build process, applications are compiled and copied from webapps to the dist folder.

After the installer is finished, it would be a good idea to stop Red5 and build it again. So in the command prompt window, make sure it has window focus and hit:
control + c

This will kill the Red5 server. Re-build the server simply by typing:
ant server

Assuming everything went well, you should be able to again navigate to:
http://localhost:5080/

This time click on the first link which talks about running Red5 demos. Click on the "view demo" link for OFLA Demo. If for some reason you cant get the web browser page again, the swf for OFLA Demo is located in webapps/root/demos

Flash Player security error when trying to connect to a local media server
When you first try and connect locally to your running Red5 server,
A successful build of Red5 running the oflaDemo application
you may get a Flash Player Security settings dialog that wont allow you to connect to localhost. If this occurs, then you have to go to the online Flash Player Global Security Settings panel and allow permissions to connect to your local red5 directory. If you are able to connect to the oflaDemo application, you should see the red5 console window acknowledge a connection then see a list of movie trailers you can stream. Click on a trailer name to stream it.

Step 11 - Solving Common Errors

Below I will list a few of the common errors I have seen recently and provide links to resources about fixing them. If none of these work for you, then please just be patient and stick with it. Red5 is a really fun tool to work with once you know how it works.

1. When trying to run the demo applications, you cant connect and the console window says "Closing RTMPMinaConnection from 127.0.0.1: to localhost with id ##### due to long handshake"

If you get the above error, its likely that you haven't installed the server instance of the demo application you are trying to connect to! Make sure you have used the installer to install the specific application you are trying to demo. Although the demos page lists and has all of the flash programs for the samples, the server doesn't come pre-installed with them if you download the source code version.

2. When trying to run the command "ant server" for the first time, you have problems with the googlecode dependencies and the build process fails.

As far as I understand, Red5 uses what is called "Ivy" to check for dependencies. I have had luck in the past clearing my ivy cache then trying to build the server again. Some of the details on this can be found in http://www.nabble.com/Groboutils-missing-again-td20095601.html Simply put, you can try and run the command:
ant ivyclear
then
ant server

which should make you start downloading .jar files again. I think this mainly happens when you have run previous versions of Red5 in the past on the same machine.

3. When trying to run any "ant" commands, you get the message ANT_HOME is set incorrectly or ant could not be located. Please set ANT_HOME.
An incorrect ANT_HOME setting example


In this instance it means you have installed java correctly, but ant isnt setup correctly. Make sure you set both the ANT_HOME environment variable and also added the path to ant's bin folder to your system path.



Comments

Edwin
Edwin
July 28, 2010 12:41 am

Thank you very much. Its very helpful to setup Red5 in my system.

Charles
Charles
June 23, 2010 2:34 pm

Oops. I meant 5080!

Charles
Charles
June 23, 2010 2:31 pm

Hi again Kashif.

You must have something already running on port 8080. On the command line of any Windows, Linux, or Mac machine you should be able to use the command "netstat -a -b" to see all of the binaries that are occupying your system's ports.

I haven't checked out the source of red5 in six months or so, but assuming the directory tree is still the same, you can change the configuration that runs tomcat on port 5080 in red5. This file can be found at:
conf/red5.properties . Under the HTTP section, you can change the port.

kashif
kashif
June 23, 2010 06:30 am

help needed

when i run project in eclipse it gives error of port in use 5080. how can i stop port i stop red 5 services manually i stop through red5-shutdown bat but it gives same error all the time 5080 port is in use so what to do.... ?

Charles
Charles
June 23, 2010 01:16 am

Kashif,

Sorry to hear you are very frustrated. Being frustrated and understanding Red5 go hand in hand.

The best resource I have seen lately are the videos on red5guide.com. I didn't watch all of them, but I think she assumes your using Eclipse, which I never do.

kashif
kashif
June 22, 2010 08:04 am

i have 3 main problems

1. the tutorials available on net are of old version of red5. so please if any one have latest tutorial link do send me.

2. when i create application it gives errors that build path is incomplete and it gives error on imports. as commons-logging file i'v download it but now it give errors there is no file or package is there in new version as mentioned in most of tutorials specialy it gives error in logging file.

3- i download commons logging package sepratly and include it to my project but now it gives error of

The type org.springframework.core.io.support.ResourcePatternResolver cannot be resolved. It is indirectly referenced from required .class files

so please do help me i realy need help GURUZ and Developers...

Niranjan Phadke
Niranjan Phadke
April 20, 2010 05:11 am

Thanks a lot for this.

Will you please help me modify and run java examples?

Thanks again.

Niranjan.phadke@gmail.com

iole
iole
February 14, 2010 11:39 am

Thanks ! It works perfect ! Juste for svn this one works perfectly [win vista] : http://subversion.tigris.org/files/documents/15/39559/svn-1.4.5-setup.exe

charles
charles
November 4, 2009 7:35 pm

Sorry that didn't help JaV. If you use "ant clean" it will delete all the compiled stuff and completely recompile everything. They try "ant server". Something I often do when I am making modifications to build.xml is to run "ant server > startuplog.txt" and then wait a while, run the commands that screw something up. They when you kill the server you will have the entire output of the startup sequence in the text file.

JaV
JaV
November 4, 2009 6:03 pm

Hi Charles, thanks for ur help but im still stuck. Its when im on http://localhost:5080/installer/, i click to install a sample, and it just hangs. I think the issue is caused by the build going wrong in step 8. I dont seem to be able to build it properly and i think that is causing trouble. If anyone can help i would really appreciate it. I am in desperate need of a working red5 server.

Charles
Charles
November 4, 2009 08:18 am

Hi JaV. In the Red5 root directory, take a look inside the dist folder. All applications before they run using this method should end up in the dist folder. Do you think it could be a permissions problem? Also, doesn't the command prompt show the URLs from where the applications are being downloaded from as its happening? Its possible that when you tried this, the server they are hosted on is having some difficulty?

JaV
JaV
November 4, 2009 00:22 am

Hi. I got through most of the setup, but at step 8 i got a build error. I had to type in ant ivyclear retrieve to get a successful build (I found this line on another site). This works, but when i get to step 10 and try to install demos, they start but never finish. It should only takes minutes but it never finishes for me so I assume there's a problem. Could you please help if u can coz i cant find any answers.

RGIA
RGIA
August 28, 2009 4:45 pm

T-H-A-N-K...UUUU 4-this posting!!! I am new to this stuff and your help has been INVALUABLE! Really appreciate you taking the time and having the heart to make my life ez!

bstephens
bstephens
August 6, 2009 3:54 pm

Nice tutorial! I was actually a bit confused by the normal Red5 docs, but this got me off the ground. Thanks!

Nizar
Nizar
June 25, 2009 11:38 am

Good job Guys Mate

Doug
Doug
June 22, 2009 06:56 am

Tried to build from within Flex Builder 3 and it almost worked but i have a couple of issues probably where JRE and Ant are coming via the Flex SDK... not sure still learning! but otherwise it's nice and easy to svn and checkout in Flex Builder (Subclipse). If i suss it i'll let you know. cheers

Doug
Doug
June 22, 2009 06:53 am

Nice work - all works for me as of June 09 with latest trunk source (0.8).

AnGeL-of-MeRcY
AnGeL-of-MeRcY
May 14, 2009 06:48 am

Thanx Mate nice post..!! :D

Name:

Message:

Avatar:
bomb avatar music player avatar email avatar nerdy tux avatar gimp avatar red hat avatar red time avatar mysterious man avatar tan smiley avatar devil smiley avatar pipe guy avatar

Complete the Re-Captcha to Post Your Message: