Showing posts with label red5. Show all posts
Showing posts with label red5. Show all posts

Friday, July 9, 2010

Problem with Red5 - SLF4JLogFactory does not implement LogFactory

I'm currently working on a team of more at least 16 developers -- the largest team I worked with on a very complicated project.

The setup is a central J2EE application that runs on JBoss, web application that written in PHP (powered by Apache web server), and a rich internet application written in ActionScript (yep, a Flash application). This Flash application communicates to Red5 server which runs on Tomcat.

If that's not complicated enough for you, continue reading.

The Flash application is a sub-application of the PHP web application. Both the PHP and Flash applications communicates to J2EE application. The PHP uses WSDL and the Flash uses Axis.

The PHP application gives data to the Flash application to let the Red5 server communicate with the J2EE application-- again, via Axis.

To make matters worse, the JBoss, Apache, and Tomcat servers are running on three different machines.

Now, when something in the process broke, it's up to the lead developers to debug it.

As I am the lead on the Flash application that communicates on Red5 server, I am oblige to find the solution.

How on Earth are you going to debug which caused which bug?

Well, the good thing in this complicated project is that it uses free and open source software and open data -- except for Adobe Flash specifics, that is. (For the record, I'm using the open source Flex SDK with FlashDevelop -- it's the Flash' SharedObject-thingy that Red5 uses I'm worried about not being open format/data)

Step-by-step, it boiled down to Red5 and Axis.

Another good thing is, a good person with a good heart by the name Jim O'Halloran, blogged about his same experience, six months earlier.

It turns out that Axis uses commons-logging.jar, which contains same classes (but not same version) of what Red5 uses. This makes the error that Red5 kept whining about:
Caused by: org.apache.commons.discovery.DiscoveryException: Class org.apache.commons.logging.impl.SLF4JLogFactory does not implement org.apache.commons.logging.LogFactory

As O'Halloran suggested, removing the JAR file for commons-logging then restarting Red5 will solve the problem. And it did!

If this helped you too, thank Jim O'Halloran. Send him beer or pizza if you could. ^^

Saturday, July 3, 2010

Using PHP with Red5

The default installation of Red5 doesn't include support for PHP. And since Red5 is ran by Tomcat, this means we need Tomcat to handle PHP.

I found a tutorial that requires you to recompile Tomcat with PHP-handling. Tedious task for a simple need of enabling PHP. Good thing, there's Quercus -- a 100% Java implementation of PHP 5. This means that it can be used with Tomcat.

What I did was, download Quercus 4.0.3 binary, then extracted file to a temporary location.

Now move the following files from the Quercus' temporary location,
  • /WEB-INF/lib/inject-16.jar
  • /WEB-INF/lib/javamail-141.jar
  • /WEB-INF/lib/resin.jar

to your Red5 installation's /webapps/root/WEB-INF/lib/{here}. Create the /lib directory on Red5's /root/WEB-INF if needed.

Now, here's the part where you need to be cautious.

From Red5's /webapps/root/WEB-INF/ location, then open web.xml.

Add the following before the </web-app> tag.
<servlet>
  <servlet-name>Quercus Servlet</servlet-name>
    <servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class>
</servlet>

<servlet-mapping>
  <servlet-name>Quercus Servlet</servlet-name>
    <url-pattern>*.php</url-pattern>
</servlet-mapping>

<welcome-file-list>
  <welcome-file>index.php</welcome-file>
</welcome-file-list>



Now, try creating a helloworld.php to test Quercus.

Make sure to restart your Red5.

Monday, June 21, 2010

Red 5: Fixing NetConnection.Connect.InvalidApp Error

Are you having problem connecting to your Red5 server? Is the error message, NetConnection.Connect.InvalidApp?

This happened to me too. Sadly, there was no available help online -- but there is now. ^^

This error occurs when your Flash application is connecting to a non-Flash-compatible service, like Skype for instance.

Skype opens a local connection at port 80 (the HTTP port). So if your Red5 is ran, it wouldn't actually be able to provide the RTMP service correctly, thus giving the NetConnection.Connect.InvalidApp error message.

What's the solution? Simply close Skype, restart Red5, and viola! Your open source media server is back running!

Sunday, March 21, 2010

AS3 and Red5

There seem to be not enough documentation about Red5 and AS3, especially on properly creating a new application, so I thought of writing one.

SOSampleAS3 is a simple Remote SharedObject demo app.The code is a modified Red5's SOSample demo which was written in Adobe Flash IDE and AS2. This is written in pure AS3 on FlashDevelop. Also, it demonstrates remote call using Shared Fridge Magnet tutorial.

How to install the demo webapp?

  1. Extract SOSampleAS3.zip.
  2. Then extract SOSampleAS3-src.zip.
  3. Copy bin directory to C:\Program Files\Red5\webapps\root so it will be:
    • C:\Program Files\Red5\webapps\root\bin\
    • C:\Program Files\Red5\webapps\root\bin\expressInstall.swf
    • C:\Program Files\Red5\webapps\root\bin\index.html
    • C:\Program Files\Red5\webapps\root\bin\SOSampleAS3.swf
    • C:\Program Files\Red5\webapps\root\bin\js\swfobject.js
  4. Extract SOSampleAS3-webapp.zip.
  5. Copy SOSampleAS3 directory to C:\Program Files\Red5\webapps so it will be:
    • C:\Program Files\Red5\webapps\SOSampleAS3\
    • C:\Program Files\Red5\webapps\SOSampleAS3\META-INF\MANIFEST.MF
    • C:\Program Files\Red5\webapps\SOSampleAS3\WEB-INF\classes\org\red5\server\webapp\elcMagnets\Application.class
    • C:\Program Files\Red5\webapps\SOSampleAS3\WEB-INF\lib\elcMagnets.jar
    • C:\Program Files\Red5\webapps\SOSampleAS3\WEB-INF\red5-web.properties
    • C:\Program Files\Red5\webapps\SOSampleAS3\WEB-INF\red5-web.xml
    • C:\Program Files\Red5\webapps\SOSampleAS3\WEB-INF\web.xml
  6. Restart your Red5 Server.
  7. Open your browser and set address to http://localhost/bin/.

That's it!