Red5 Trunk Development - Revisited
So, I know I just posted about using the latest version of Red5 two days ago, but I feel like I was a bit brief on the subject and that there's much more to cover. It is my experience that a lot can go wrong in using Red5, so it's better to write a post that's more exhaustive than thin. Anyways, let's dive into it.
Comparing Red5 Trunk to 0.7:
There are a lot of differences in using the latest trunk versus using previous releases. The latest trunk (as of the time of this post's writing, revision 3332) utilizes the concept of "distributions," allowing you as a user to create as many Red5 servers as you can put your mind to. When reviewing the build.xml file, you should see a build target called "dist". This is the default target of the build file in Ant. When you issue "ant" from command line in this folder, the "dist" target will be called. (Likewise, you can call "ant dist" from command line, but it achieves the same result.)
Before going over what "dist" does, we need to do some brain washing. In 0.7 and before, when you need to start Red5, you go to Red5's home directory and call either the red5 or the red5-debug script. In the trunk, if you try doing this, you will be rewarded with tons of errors. Why? Because Red5 Trunk is meant to be started as a distribution, not as its own stand alone server. What does this mean for you? Well, firstly you need to understand this so-called concept of distributions.
Ok, now we can cover the Ant "dist" target. The "dist" target relies on one other target, the "jar" target. The JAR target does the following:
Distributions allow you to do a whole lot. Let's talk about some of the advantages of using distributions. First, let's say you're working on Red5 and you believe you found a new way to handle connections that would be a lot faster than the old way. (This is actually something that happened, by the way) You open up Eclipse to work on the Red5 source code, and create a new class: "org.red5.server.adapter.MultiThreadedApplicationAdapter". To test it, you would create a few distributions of Red5 by modifying the "dist.dir" property in the build.xml file. You could create the old version in a folder called "dist_old_way" and the new version employing MultiThreadedApplicationAdapter in a folder named "dist_new_way". To do this, you'd edit the "dist.dir" property in the Red5/build.xml file from this:
Another useful feature of using distributions is allowing for versioning of your distributions. As suggested by a member of the Red5 team, you could create distributions in directories like "dist_3324" and "dist_2345" to test features against different distributions. Ok, I believe that we've covered the concept of distributions quite thoroughly, so we'll move on to the next topic.
*Note: In Red5's default configuration, you can not run more than one instance of Red5 on one machine at a time. If you get a "BindException" when running your startup script, you probably have another Red5 running in the background. Be sure to shut it down. There are ways to allow for more than one Red5 instance on one machine, but it involves modifying ports that Red5 uses and that concept is beyond the scope of this tutorial but will hopefully be covered in a future tutorial by me or another Red5 user.
*Another Note: Do not try starting Red5 from the scripts contained in the base directory. They won't work. Don't do it! DON'T! Remember, you're using distributions now! Start Red5 from the scripts in the distribution's base folder. This is to save you weeks of frustration that I was unlucky enough to face.
red5-bootstrap vs. red5-debug, what the heck?
In the latest trunk, you may have noticed the new red5-bootstrap script. This is new since Red5 0.7 and I will explain it now. A lot of people including me have had problems using the standard red5 and red5-debug scripts to start the server in the latest trunk version. This is due to a problem with Red5's way of dealing with classpath entities. For more information on it, I suggest you post to the mailing list (red5@osflash.org). I myself have no idea when this will be fixed or if it is even being planned for being fixed. All that I know is that it's an issue with creating distributions. There is also a bug with the current Red5, again at the time of this post's writing, that creates problems when including required JAR files in a web application's /lib folder. I myself have not experienced this problem in particular, but that is because I put all of my required libraries, such as Hibernate libraries, inside of my distribution's global /lib folder. Let's just say I'm a little paranoid about errors and if I can avoid them, at all costs I will. Again, I'm not even sure if this is a bug or not, but I have seen posts in the mailing list concerning this many times.
So, all you really need to know is that the red5 and red5-debug scripts won't find JARs that you placed in your distribution's /lib folder. red5-bootstrap will find them. Here's a really handy rule, always favor red5-bootstrap. Again, it will save you hours of frustration. However, when you run the script, you may notice something. The red5-bootstrap script issues no output to command line when you open it up. It either says "Starting Red5 (org.red5.server.Bootstrap)..." or nothing at all and that's it. Let's address this.
Red5 is running invisibly?
It may appear after trying to run the red5-bootstrap script that Red5 is doing nothing or it's suspended. Well, there's no need to fear, the output is just going somewhere else, not to your console. The latest Red5 (rev 3332) addresses a problem that has been long existent in Red5. For the longest time, Red5 had problems with using common logging utilities in Java such as log4j and sl4j. This has now been fixed. I myself am not currently using a logging utility so I can't tell you how to get up and running with that, and besides, that's beyond the scope of what we're doing here.
For now, let's modify the red5-bootstrap script in your distribution's directory. Alternatively, you can edit the master script in the Red5 base directory to ensure that all future distributions you create have the changes applied to them and you won't have to change red5-bootstrap every time you create a new distribution. It's your call what to do, but open the red5-bootstrap script of your choosing, relative to your operating system. IE: For Windows, open the red5-bootstrap.bat file in Notepad, for other operating systems open the red5-bootstrap.sh file in a text editor. The last line in this script is the one of interest. It should read somewhat as so: (note, it will look different depending on whether you're editing the .bat or .sh script)
And that it's referenced in the "root" element in that file as so:
Changes in an application's web.xml file since 0.7:
Another thing that has changed since 0.7 is in the way that your web-app definition file ("web.xml") is constructed. There have been a few major changes in the way that this file defines applications that will throw major errors and exceptions on startup. If you are seeing some very strange errors around startup of a distribution of Red5, validate that all of your applications' web.xml files have been updated if you are migrating them to the trunk server. For more information on how these files should be constructed, post to the mailing list. I myself am not too familiar with modifying these files, excepting of course the modification of the webAppRootKey property.
Hopefully this has been very helpful in getting set up to work with the latest Red5. If you have any questions or notice an error, please comment back to this post. For some of the concepts covered here, such as the web.xml file, please send messages to the mailing list, as I'm pretty unfamiliar with the modification of that file. Long live Red5!
*Note: When I refer to something as a script, IE: "the red5-debug script", I am referring to a file with the extension of either *.bat or *.sh
Comparing Red5 Trunk to 0.7:
There are a lot of differences in using the latest trunk versus using previous releases. The latest trunk (as of the time of this post's writing, revision 3332) utilizes the concept of "distributions," allowing you as a user to create as many Red5 servers as you can put your mind to. When reviewing the build.xml file, you should see a build target called "dist". This is the default target of the build file in Ant. When you issue "ant" from command line in this folder, the "dist" target will be called. (Likewise, you can call "ant dist" from command line, but it achieves the same result.)
Before going over what "dist" does, we need to do some brain washing. In 0.7 and before, when you need to start Red5, you go to Red5's home directory and call either the red5 or the red5-debug script. In the trunk, if you try doing this, you will be rewarded with tons of errors. Why? Because Red5 Trunk is meant to be started as a distribution, not as its own stand alone server. What does this mean for you? Well, firstly you need to understand this so-called concept of distributions.
Ok, now we can cover the Ant "dist" target. The "dist" target relies on one other target, the "jar" target. The JAR target does the following:
- Calls Ivy to start downloading the dependencies of Red5. Using Ivy is beyond the scope of this tutorial, but basically here's what happens. Red5 has declared that it depends on certain external JAR files that do not natively exist in the repository. Ivy contacts web sites and downloads the JAR's that Red5 needs. They are downloaded to a folder on your computer (usually a folder named .ivy2, its location varies based on your OS) called the Ivy "cache," then they are copied to the Red5/lib folder. You need to have internet access the first time you try and compile Red5 for this reason. Red5 won't compile if it can't get the JAR's it needs.
- Compiles all of the Java source files located in the Red5/src folder to the Red5/bin folder. If you can't see why this is necessary, you need to learn a whole lot more about Java.
- It then creates a JAR archive of Red5 with a manifest file declaring some attributes about the version and other things such as the Red5's classpath. The JAR file is output to Red5/red5.jar.
Distributions allow you to do a whole lot. Let's talk about some of the advantages of using distributions. First, let's say you're working on Red5 and you believe you found a new way to handle connections that would be a lot faster than the old way. (This is actually something that happened, by the way) You open up Eclipse to work on the Red5 source code, and create a new class: "org.red5.server.adapter.MultiThreadedApplicationAdapter". To test it, you would create a few distributions of Red5 by modifying the "dist.dir" property in the build.xml file. You could create the old version in a folder called "dist_old_way" and the new version employing MultiThreadedApplicationAdapter in a folder named "dist_new_way". To do this, you'd edit the "dist.dir" property in the Red5/build.xml file from this:
<property name="dist.dir" value="dist"/>To this:
<property name="dist.dir" value="dist_old_way"/>After doing so, you'd issue "ant" from command line in the Red5 home directory. This would create your distribution in the "dist_old_way" directory. Likewise, you'd create the "dist_new_way" distribution. You'd then start the 'old way' distribution by running the red5-bootstrap script in the directory you specified, ie: "dist_old_way/red5-bootstrap.sh" or "dist_old_way/red5-bootstrap.bat". It would start the server, you'd do some time tests, then create the new distribution with your modifications in the "dist_new_way" directory and run some tests against it. You'd then find out that MultiThreadedApplicationAdapter is much faster than ApplicationAdapter.
Another useful feature of using distributions is allowing for versioning of your distributions. As suggested by a member of the Red5 team, you could create distributions in directories like "dist_3324" and "dist_2345" to test features against different distributions. Ok, I believe that we've covered the concept of distributions quite thoroughly, so we'll move on to the next topic.
*Note: In Red5's default configuration, you can not run more than one instance of Red5 on one machine at a time. If you get a "BindException" when running your startup script, you probably have another Red5 running in the background. Be sure to shut it down. There are ways to allow for more than one Red5 instance on one machine, but it involves modifying ports that Red5 uses and that concept is beyond the scope of this tutorial but will hopefully be covered in a future tutorial by me or another Red5 user.
*Another Note: Do not try starting Red5 from the scripts contained in the base directory. They won't work. Don't do it! DON'T! Remember, you're using distributions now! Start Red5 from the scripts in the distribution's base folder. This is to save you weeks of frustration that I was unlucky enough to face.
red5-bootstrap vs. red5-debug, what the heck?
In the latest trunk, you may have noticed the new red5-bootstrap script. This is new since Red5 0.7 and I will explain it now. A lot of people including me have had problems using the standard red5 and red5-debug scripts to start the server in the latest trunk version. This is due to a problem with Red5's way of dealing with classpath entities. For more information on it, I suggest you post to the mailing list (red5@osflash.org). I myself have no idea when this will be fixed or if it is even being planned for being fixed. All that I know is that it's an issue with creating distributions. There is also a bug with the current Red5, again at the time of this post's writing, that creates problems when including required JAR files in a web application's /lib folder. I myself have not experienced this problem in particular, but that is because I put all of my required libraries, such as Hibernate libraries, inside of my distribution's global /lib folder. Let's just say I'm a little paranoid about errors and if I can avoid them, at all costs I will. Again, I'm not even sure if this is a bug or not, but I have seen posts in the mailing list concerning this many times.
So, all you really need to know is that the red5 and red5-debug scripts won't find JARs that you placed in your distribution's /lib folder. red5-bootstrap will find them. Here's a really handy rule, always favor red5-bootstrap. Again, it will save you hours of frustration. However, when you run the script, you may notice something. The red5-bootstrap script issues no output to command line when you open it up. It either says "Starting Red5 (org.red5.server.Bootstrap)..." or nothing at all and that's it. Let's address this.
Red5 is running invisibly?
It may appear after trying to run the red5-bootstrap script that Red5 is doing nothing or it's suspended. Well, there's no need to fear, the output is just going somewhere else, not to your console. The latest Red5 (rev 3332) addresses a problem that has been long existent in Red5. For the longest time, Red5 had problems with using common logging utilities in Java such as log4j and sl4j. This has now been fixed. I myself am not currently using a logging utility so I can't tell you how to get up and running with that, and besides, that's beyond the scope of what we're doing here.
For now, let's modify the red5-bootstrap script in your distribution's directory. Alternatively, you can edit the master script in the Red5 base directory to ensure that all future distributions you create have the changes applied to them and you won't have to change red5-bootstrap every time you create a new distribution. It's your call what to do, but open the red5-bootstrap script of your choosing, relative to your operating system. IE: For Windows, open the red5-bootstrap.bat file in Notepad, for other operating systems open the red5-bootstrap.sh file in a text editor. The last line in this script is the one of interest. It should read somewhat as so: (note, it will look different depending on whether you're editing the .bat or .sh script)
red5-bootstrap.bat file:What you need to do now is change the last line of the script. You should change the script to simply read as so:
%RED5_HOME%\red5.bat 1>%RED5_HOME\log\stdout.log 2>%RED5_HOME%\log\stderr.log
red5-bootstrap.sh file:
exec $RED5_HOME/red5.sh 1>$RED5_HOME/log/stdout.log 2>$RED5_HOME/log/stderr.log
red5-bootstrap.bat file:After doing that, shut down Red5 if it is running, then start it with red5-bootstrap in your distribution's directory. Note: if you modified the master red5-bootstrap script in the Red5 base directory, you need to copy it to your existing distributions' folders. You should see output in your console. If you are still not seeing any output, make sure that you have the following entry in your distribution's conf/logback.xml file:
%RED5_HOME%\red5.bat
red5-bootstrap.sh file:
exec $RED5_HOME/red5.sh
<appender name="CONSOLE"
class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>[%p] [%thread] %logger - %msg%n</Pattern>
</layout>
</appender>
And that it's referenced in the "root" element in that file as so:
<root>If you're still having problems with this, comment back to this post and/or post to the mailing list.
<level value="DEBUG" />
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
<appender-ref ref="ERRORFILE" />
</root>
Changes in an application's web.xml file since 0.7:
Another thing that has changed since 0.7 is in the way that your web-app definition file ("web.xml") is constructed. There have been a few major changes in the way that this file defines applications that will throw major errors and exceptions on startup. If you are seeing some very strange errors around startup of a distribution of Red5, validate that all of your applications' web.xml files have been updated if you are migrating them to the trunk server. For more information on how these files should be constructed, post to the mailing list. I myself am not too familiar with modifying these files, excepting of course the modification of the webAppRootKey property.
Hopefully this has been very helpful in getting set up to work with the latest Red5. If you have any questions or notice an error, please comment back to this post. For some of the concepts covered here, such as the web.xml file, please send messages to the mailing list, as I'm pretty unfamiliar with the modification of that file. Long live Red5!
*Note: When I refer to something as a script, IE: "the red5-debug script", I am referring to a file with the extension of either *.bat or *.sh
Labels: java, red5, subversion, trunk
9 Comments:
Thanks for the detailed article. This is a lot easier then trying to assemble a bunch of posts on the mailing list.
I dont have red5 deployed anywhere, but normally run it for development using build.xml in the root directory. What is that method called? Is it either of the ways of running red5 that you mentioned?
If you run "ant server" to start the server from the Red5 home directory, it by default creates a distribution in the "/dist" folder and starts the server in Standalone mode.
You see, the scripts in the Red5 home directory are more or less a "red herring," they don't work and are meant to be copied to the distribution's home directory. That really threw me off for a while. But anyway, you can start Red5 via "ant server" much in the same way as running one of the scripts, the scripts are just there for convenience :)
This comment has been removed by the author.
Thank you for the great post. It is very hard thing to build red5 from the trunk for me.
What you think: can I use ant – embedded in eclipse and IvyDE to build instead of command line?
When I try modified red5-bootstrap.bat(and any other)script I get this errors:
Starting Red5 (org.red5.server.Bootstrap)
Exception in thread "main" java.security.AccessControlException: access denied (
java.util.PropertyPermission red5.root read)
at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:323)
at java.security.AccessController.checkPermission(AccessController.java:
546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:12
85)
at java.lang.System.getProperty(System.java:652)
at org.red5.server.Bootstrap.getRed5Root(Bootstrap.java:197)
at org.red5.server.Bootstrap.main(Bootstrap.java:60)
Are you encounter same problem ?
Thanks.
When I set up RED5_HOME env. var. - sever begin works (red5-bootstrap.bat and red5.bat are works).
My experience is that if you just run an "ant clean" command to delete the "dist" directory, then run "ant dist" to regenerate that directory, it'll work. The RED5_HOME environment variable should be set by default by the startup scripts.
It’s seems that ant dist – works good (but RED5_HOME I set up manually), but
I need to note one thing: in Eclipse I didn’t get from errors associated with build path, and when I make three copy of red5-server-java6.xml file with names: red5-server-default.xml, red5-server-java5.xml, red5-server-utest.xml in ivy cash folder – all was resolved with IvyDE. Yes, it is ugly, but I can’t resolve this by another way, and I don’t understand why it happens.
Thanks.
Hi All, I use red5 trunk lastest version . And I build red5 ok but it don't work. I can't run sample in webapp and can't open localhost:5080
You can see all cmd
*********************************************************
D:\Program Files\Red5>set java_home
JAVA_HOME=C:\Program Files\Java\jdk1.6.0_06
D:\Program Files\Red5>set java_version
JAVA_VERSION=1.6
D:\Program Files\Red5>set ant_home
ANT_HOME=D:\Program Files\Ant
D:\Program Files\Red5>set red5_home
RED5_HOME=D:\Program Files\Red5
D:\Program Files\Red5>ant dist
Buildfile: build.xml
-library.check:
[echo] Java: java.home is C:\Program Files\Java\jdk1.6.0_06\jre and the tar
get version is 1.6
[echo] Ant: ant.home is D:\Program Files\Ant and the target version is Apac
he Ant version 1.7.1 compiled on June 27 2008
-java6.check:
[echo] Using Java 1.6
prepare:
compile:
[echo] javac version: 1.6
[echo] Not using the Eclipse IDE
[echo] Compiler adapter name: modern
compile-core:
retrieve:
[echo] Ivy conf name: java6
[ivy:resolve] :: Ivy 2.0.0-rc1-local-20080903101936 - 20080903101936 :: http://a
nt.apache.org/ivy/ ::
:: loading settings :: file = D:\Program Files\Red5\ivysettings.xml
[ivy:resolve] :: resolving dependencies :: red5#server;working@vy_thanh
[ivy:resolve] confs: [java6]
[ivy:resolve] found tomcat#jasper;6.0.18 in googlecode
[ivy:resolve] found tomcat#jasper-jdt;6.0.18 in googlecode
[ivy:resolve] found tomcat#jasper-el;6.0.18 in googlecode
[ivy:resolve] found tomcat#el-api; in default
[ivy:resolve] found javax#jsp-api;2.1 in default
[ivy:resolve] found javax#servlet-api;2.5 in default
[ivy:resolve] found javax#ejb3-persistence; in googlecode
[ivy:resolve] found red5#naming-factory; in default
[ivy:resolve] found red5#naming-resources; in default
[ivy:resolve] found spring#spring-aop;2.5.6 in googlecode
[ivy:resolve] found spring#spring-beans;2.5.6 in googlecode
[ivy:resolve] found spring#spring-context;2.5.6 in googlecode
[ivy:resolve] found spring#spring-core;2.5.6 in googlecode
[ivy:resolve] found spring#spring-web;2.5.6 in googlecode
[ivy:resolve] found spring#aopalliance; in default
[ivy:resolve] found tomcat#catalina;6.0.18 in googlecode
[ivy:resolve] found tomcat#tomcat-coyote;6.0.18 in googlecode
[ivy:resolve] found tomcat#annotations-api; in default
[ivy:resolve] found commons#commons-modeler;2.0.1 in default
[ivy:resolve] found jetty#jetty;6.1.9 in googlecode
[ivy:resolve] found jetty#jetty-util;6.1.9 in googlecode
[ivy:resolve] found jetty#jetty-xbean;6.1.9 in googlecode
[ivy:resolve] found red5#slf4j-api;1.5.6 in googlecode
[ivy:resolve] found red5#jcl-over-slf4j;1.5.6 in googlecode
[ivy:resolve] found red5#log4j-over-slf4j;1.5.6 in googlecode
[ivy:resolve] found red5#jul-to-slf4j;1.5.6 in googlecode
[ivy:resolve] found red5#logback-core;0.9.14 in googlecode
[ivy:resolve] found red5#logback-classic;0.9.14 in googlecode
[ivy:resolve] found red5#tomcat-juli-slf4j;1.5.0 in googlecode
[ivy:resolve] found commons#commons-beanutils;1.8.0 in googlecode
[ivy:resolve] found commons#commons-codec;1.3 in default
[ivy:resolve] found commons#commons-collections;3.2.1 in googlecode
[ivy:resolve] found commons#commons-httpclient;3.1 in default
[ivy:resolve] found commons#commons-lang;2.4 in googlecode
[ivy:resolve] found commons#commons-pool;1.4 in googlecode
[ivy:resolve] found red5#quartz;1.6.1 in googlecode
[ivy:resolve] found javax#jta;1.1 in googlecode
[ivy:resolve] found red5#ehcache;1.6.0-beta1 in googlecode
[ivy:resolve] found javax#activation;1.1 in default
[ivy:resolve] found red5#xercesImpl;2.9.1 in googlecode
[ivy:resolve] found red5#xml-apis;2.9.1 in googlecode
[ivy:resolve] found red5#xmlrpc;2.0.1 in default
[ivy:resolve] found mina#mina-core;1.1.7 in googlecode
[ivy:resolve] found mina#mina-filter-ssl;1.1.7 in googlecode
[ivy:resolve] found mina#mina-integration-spring;1.1.7 in googlecode
[ivy:resolve] found mina#mina-integration-jmx;1.1.7 in googlecode
[ivy:resolve] found asm#asm;2.2.3 in local
[ivy:resolve] found asm#asm-commons;2.2.3 in local
[ivy:resolve] found asm#asm-tree;2.2.3 in local
[ivy:resolve] found antlr#antlr;2.7.6 in local
[ivy:resolve] found red5#groovy;1.0 in default
[ivy:resolve] found red5#jython;2.5 in googlecode
[ivy:resolve] found spring#spring-context-support;2.5.6 in googlecode
[ivy:resolve] found red5#jacksum;1.7.0 in googlecode
[ivy:resolve] found red5#jaudiotagger;1.0.8 in googlecode
[ivy:resolve] found red5#jruby;1.0.3 in default
[ivy:resolve] found red5#bcprov-jdk16;139 in googlecode
[ivy:resolve] :: resolution report :: resolve 1297ms :: artifacts dl 62ms
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| java6 | 57 | 0 | 0 | 0 || 57 | 0 |
---------------------------------------------------------------------
[ivy:retrieve] :: retrieving :: red5#server
[ivy:retrieve] confs: [java6]
[ivy:retrieve] 0 artifacts copied, 57 already retrieved (0kB/62ms)
compile-core-compatibility:
compile-demos:
[echo] Webapps dir: webapps
[echo] Webapps build dir: dist/webapps
prepare:
compile-script:
[echo] Scripting compatibility is available.
jar-determine-classpath:
jar:
dist:
BUILD SUCCESSFUL
Total time: 6 seconds
D:\Program Files\Red5>red5.bat
Starting Red5
The very latest trunk has had some significant changes to it that fix some problems that have plagued Red5 for a very long time.
What are you doing that isn't working? There shouldn't be a red5-bootstrap file anymore. It looks like you're not getting output to your console, but that Red5 is starting fine. Follow my instructions above about getting logging to work. Just modify the red5.bat/sh file rather than the nonexistent red5-bootstrap.bat/sh file.
Post a Comment
Subscribe to Post Comments [Atom]
<< Home