Red5[1] contributor Paul Gregoire recently added a new server startup script targeted specifically at application debugging. The script is quite simple in nature and is provided in both Windows and Unix flavors. Take note, however, that this script is exclusive to the standalone version of Red5. Debugging the WAR version of the server is quite a different task. To demonstrate the ease of debugging your applications, I’ll walk through a simple example using Eclipse[2] and the source code from my stream recording tutorial.
First things first, you’ll want to make sure you have the latest code from Red5’s subversion repository. If you do not run against trunk, fear not, you’ll just need to create the scripts manually. Both versions are shown here:
Windows
@echo off set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y if not "%JAVA_HOME%" == "" goto launchRed5 :launchRed5 "%JAVA_HOME%/bin/java" -Djava.security.manager -Djava.security.policy=conf/red5.policy %JAVA_OPTS% -cp red5.jar;conf;bin;%CLASSPATH% org.red5.server.Standalone goto finaly :err echo JAVA_HOME environment variable not set! Take a look at the readme. pause :finaly pause
Unix
#!/bin/bash
JAVA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y"
for JAVA in "$JAVA_HOME/bin/java" "/usr/bin/java" "/usr/local/bin/java"
do
if [ -x $JAVA ]
then
break
fi
done
if [ ! -x $JAVA ]
then
echo "Unable to locate java. Please set JAVA_HOME environment variable."
exit
fi
# start red5
exec $JAVA -Djava.security.manager -Djava.security.policy=conf/red5.policy $JAVA_OPTS -cp red5.jar:conf:$CLASSPATH org.red5.server.Standalone
Make sure you’ve got the file permissions set correctly on Unix platforms. If not, updating the file permissions is as simple as chmod 755 red5_debug.sh. Double check to insure that your application is installed in the Red5 webapps directory and configured properly. If not, you’ll need to deploy it now. Start the server from the console. Don’t expect to see the normal server log statements just yet. The only statement we are interested in at this point is “Listening for transport dt_socket at address: 8787“. You should be seeing something like this:
Next, we’ll need to create a debugging profile in Eclipse. Start it now if it is not already running and make sure that your project is open in the workspace. Mine looks something like this:
Find the small bug icon in the Eclipse toolbar, click it and choose “Open Debug Dialog...“. Select the “Remote Java Application” entry in the list, then right click and choose “New“. By default, Eclipse will name this debugging profile after the class you currently have selected in the editor. I’ve changed it to reflect the name of the project I’m working with at the moment. The only other changes we need to make are to alter the default port number from 8000 to 8787 and check the “Allow termination of remote VM” box. The second step here is not really necessary, but I like having the option to kill the remote server from Eclipse. Here’s what you should have:
Click “Apply“, then “Debug“. Eclipse has now attached a socket listener to the remote JVM and Red5 should be starting in the console window you opened earlier, complete with all of the standard logging output shown here:
If you’ve never opened the debugging perspective in Eclipse before, it should prompt you to do so. If not, select “Window --> Open Perspective --> Debug“. Select the line at which you would like to set a breakpoint and double click in the gutter. The debug perspective should have appeared and you should see your breakpoint:
At this point you’ll need to start the execution path of your application. Fire up your flash or flex app and connect to Red5. For this example, I’ve opened a browser and pointed it at the broadcast SWF of my stream recording tutorial. Given that you are using the same project I am, you should see this (Sans my ugly mug, of course.):
Upon triggering your breakpoint, your application will cease to respond and Eclipse should come into focus. The debugger will highlight the line of code next in the execution tree. You’ll see something like the following:
That’s it! You are now debugging your Red5 application. If you aren’t sure what to do next, I would suggest that you read this article over at IBM’s developerWorks.
With these startup scripts, it is even possible to debug Red5 itself. You’ll need to have the latest code checked out from Subversion and the project open in Eclipse. Start the server in the same manner, create or open the debug profile and start debugging.
1. http://osflash.org/red5 For those that aren’t up on Red5, it is a robust Flash Media Server alternative written entirely in Java that supports multi-user video chat, video streaming and real-time, multi-player gaming.
2. www.eclipse.org Eclipse is an open source community whose projects are focused on building an open development platform comprised of extensible frameworks, tools and runtimes for building, deploying and managing software across the lifecycle.
Carl Sziebert is a loving husband, devoted father, and accomplished software engineer, living and working in the San Francisco Bay Area. He is no stranger to code, having spent the better part of a decade developing software for a diverse range of organizations, including small startups, large corporations, and government agencies. Having built a solid foundation of skills from these experiences, Carl now works as an engineer at 





8 Comments
Hi,your tutorial is very clear, but I can’t find red5_debug.sh
I’m using red5 0.6.3 standalone Windows version.
thanks for your help!
@Matteo:
The scripts do not yet exist in a released version. You’ll have to create the scripts yourself using the examples I included above in the article. The only other option is to check out the latest version of Red5 from Subversion.
Doing this under WinXP and Intellij IDEA.
When starting the batch script – all the full log is writing out into the console straight away. It behaves like an obvious start up of the Red5 server. And there is no any message in the top like “Listening for transport dt_socket at address: 8787“. Maybe it’s normal to Windows?…
But when I’m starting debugging in my IDE it says: “Error running : Unable to open debugger port: java.net.ConnectException ‘Connection refused: connect’”
I suppose that second one is the consequence of the first step. What do you think?
Well, I got it.
In my environment it gave a result when I write in a batch-file:
“%JAVA_HOME%/bin/java” -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8787 -Djava.security.manager -Djava.security.policy=conf/red5.policy -cp red5.jar;conf;bin;%CLASSPATH% org.red5.server.Standalone
That is, I’ve put JAVA_OPTS into string where StandAlone application in fact is launched.
Then, it writes:
d:\Program Files\Red5>red5-debug.bat
Listening for transport dt_socket at address: 8787
and continues to write out all the full log of red5. But, now it’s not a problem, just a difference in this between my Win and your *nix cases.
So, it’s working
, thanks for pointing the way.
P.S.
Why it ignores the set JAVA_OPTS – it’s another talk.
I had installed red5 on my windows localhost.I want to install this red5 on my linux server using http://ftp.But i dont know the procedure.one more thing my hosting server is not in my circumstances.i have to install red5 in my server from my local host.What is the procedure? Please mail me at kiran.y2cs214@gmail.com
Nice and clean tutorial.I will test it. I have worked on Red5 and found it great.
I’m very much a newbie and think your tutorial is really good. I’ve got a satndlone red5 server and the debug script installed and working on linux server. I have managed to signout the source code for oflaDemo and ran as ant build which created the war file which I then put in the webapps folder (after moving the oflaDemo folder that was already there to backup), restarted red5 and hey presto I had oflaDemo which was from my build. When trying to use debug in eclipse it starts with saying it cant run cause there was no recent task ran, as in running the oflademo from eclipse (which I dont know how to do). I tried the debug, new, remote app and tried to create a profile but it would save. Which fiel/project/folder should i hightlight when I lcick debug. Why does my version of eclipse not have debug->new option. I have debug then an option for debug configuration, a popup with remote app in the list but when I try and create it it cant find project. I think I need to run the project in eclipse first, maybe? then debug. I’d really like to figure this out, any advice you have would be great. Thanks Zc
Follow up: I’ve tried it at work on windows, java ee version of eclipse and it seems to setup debug profile okay, do I need to debug the build.xml/appliocation.java file??? will change eclipse version at home and try again, really would like to know which file needs to be debugged??? Thanks again.
3 Trackbacks
[...] seve seve burdan da yayınlar yada link verebiliriz..
Konuyla ilgili iki blog postu: Remote debugging Red5 applications , Flash on the Beach 2007 Presentation Followup [...]
[...] Red5[1] contributor Paul Gregoire recently added a new server startup script targeted specifically at application debugging. The script is quite simple in nature and is provided in both Windows and Unix flavors. Take note, however, that this script is exclusive to the standalone version of Red5. Debugging the WAR version of the server is quite a different task. To demonstrate the ease of debugging your applications, I’ll walk through a simple example using Eclipse[2] and the source code from my stream recording tutorial. [...]
[...] debug of the hypervisor … debugging on xen PV online linked to this post on October 21, 2009 …Carl Sziebert Remote debugging Red5 applicationsRed5[1] contributor Paul Gregoire recently added a new server startup script targeted specifically [...]