Thursday, September 3, 2009

RTMPT on Tomat + Red5 as a war

I'm recently developing a Flex application and, as an Open Source addicted, I choosen to use Red5 as streaming server.

The network architecture actually is a Tomcat 6 servlet container with some wars deployed within, one of which is the Red5 streaming server.

To ensure my application could be used through internet the default RTMP protocol is not the best choice as some firewalls blocks its port, so I opted for the RTMP over HTTP, also known as RTMPT (notice the final additional T) which is able to tunnel RTMP inside HTTP.

I found a bit of confusion when I googled to configure my Red5 war so I'm going to report here the simple four steps I did to make my configuration working.

  1. Open your WEB-INF/web.xml file and add the RTMPT servlet definition and mappings (if RTMP is going to be tunneled inside HTTP we need an HTTP endpoint able to forward packets)







  2. Inside your WEB/lib you should have a Red5 jar (well, this is not my case as I use Maven for build, but Maven users will understand what I mean, right?) and you need to open it up and edit the file it contains:

    http.port = 8080

  3. Open your Tomcat 6 folder and edit the file conf/server.xml adding, if needed, an HTTP/1.1 connector for the port you want to use for RTMPT (the default port is 80, but you can set it accordingly to your needs):

    <!-- RTMPT connector redirecting to your HTTP port -->
    <Connector port="8088" protocol="HTTP/1.1"
    maxThreads="150" connectionTimeout="20000"
    redirectPort="8080" />

  4. The last and very bothering part is you need to have your streaming server war binded to the root context, so you can simply rename it to ROOT.war


jayachand said...

I followed your process with self signed certificate in tomcati got security alert message but i got connection failed messsage in debug .but in red5 server every thing is fine.

The connection is success in red5 server with self signed certificate but the same process is used in Tomcat with self signed certificate the connection is failed.
but rtmp connectin is success.

is ther any difference between red5 server and web server (having red5 war) to rtmps ?

is there any diff in auth & self signed certificate to web server(having red5 war) to rtmps ?

Gianfranco Imbrogno said...

Tomcat 5.x and JBoss 4.x need a different configuration to be able to use RTMPT protocol.
You must configure the connector adding the following lines to server.xml

< Connector port="8088" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8080" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />

ramu said...

Hi Roberto,
Can you please tell me the versions of Red5.war and tomcat. I am facing problem with newer releases.

Thanking you.