msgbartop
Various ramblings-on, mostly about Red5
msgbarbottom

28 Jan 09 RTMPT and Red5

By default or so I’ve been told, the Flash Player will try various ports when attempting to connect to a resource. In Red5, RTMP is supported out-of-the-box on the default RTMP port of 1935 and HTTP is setup on 5080. A “special” server is started on 8088 as well to handle RTMPT only requests, but this requires that you set your request url as “rtmpt://myserver:8088/myapp/” which can be confusing and completely ignores the Flash Player port probing. So I offer this solution, allowing you to setup HTTP on port 80 and RTMPT on port 80 as well. Since Red5 includes a servlet container (Tomcat by default), you have a full-fledged HTTP server and servlet engine built-in; allowing a servlet to answer the RTMPT requests.
The first file we need to modify is the server properties file located in the conf directory:
red5/conf/red5.properties

  • Locate the http.port key and change it to 80 instead of 5080
  • Do not change the rtmpt.port entry, it should be 8088
  • Save and close the file

The last file to modify will be your web application configuration or “web.xml” file. The web application configuration file will be located here: red5/webapps/myapp/WEB-INF/web.xml if your application name is “myapp”. Add these entries:

    
   	<servlet>
		<servlet-name>rtmpt</servlet-name>
		<servlet-class>org.red5.server.net.rtmpt.RTMPTServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
    
	<servlet-mapping>
		<servlet-name>rtmpt</servlet-name>
		<url-pattern>/fcs/*</url-pattern>
	</servlet-mapping>

	<servlet-mapping>
		<servlet-name>rtmpt</servlet-name>
		<url-pattern>/open/*</url-pattern>
	</servlet-mapping>

	<servlet-mapping>
		<servlet-name>rtmpt</servlet-name>
		<url-pattern>/close/*</url-pattern>
	</servlet-mapping>

	<servlet-mapping>
		<servlet-name>rtmpt</servlet-name>
		<url-pattern>/send/*</url-pattern>
	</servlet-mapping>

	<servlet-mapping>
		<servlet-name>rtmpt</servlet-name>
		<url-pattern>/idle/*</url-pattern>
	</servlet-mapping>

Informational links about FlashPlayer and ports:
HTTP Tunneling protocols

The Trouble with Proxy Servers

Tags: , , , , , , ,



Reader's Comments

  1. |

    RTMPTServlet requires handler and connectionManager to be set from Spring context. But how it’s wired in web.xml?

  2. |

    I have change http.port, and modify the web.xml in myapp/WEBINF folder.
    Red5 start, but streaming doesn’t work (working good in the 8088 port).
    Is there anything else to do?

  3. |

    Thanks. This works, well. I had to change the XML to this, though:

    rtmpt
    org.red5.server.net.rtmpt.RTMPTServlet
    1

    rtmpt
    /fcs/*

    rtmpt
    /open/*

    rtmpt
    >/close/*

    rtmpt
    >/send/*

    rtmpt
    >/idle/*

    Probably got munged in cutting and pasting?

  4. |

    Yup. Got munged.

    <servlet>
    <servlet-name>rtmpt</servlet-name>
    <servlet-class>org.red5.server.net.rtmpt.RTMPTServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
    <servlet-name>rtmpt</servlet-name>
    <url-pattern>/fcs/*</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>rtmpt</servlet-name>
    <url-pattern>/open/*</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>rtmpt</servlet-name>
    <url-pattern>>/close/*</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>rtmpt</servlet-name>
    <url-pattern>>/send/*</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>rtmpt</servlet-name>
    <url-pattern>>/idle/*</url-pattern>
    </servlet-mapping>

  5. |

    Dear Paul!

    Sorry for disturbance, but I totally stucked at building my video streaming Red5 application. This is the reason why I ask for your help. My problem is about event handling: I try catch and handle, when flash applet pauses the video play. In theory the applet sends a pause notification to the application on the server, what I can handle, but anyhow I log, and try to discover the flow of the event, I can’t see. I found ACTION_PAUSE and others, but I couldn’t find the part where a handler method will called automagically. I read a lot of things in documentation, and google, but I saw just actionscript example, there was nothing worthwhile about server’s pause handling (or I just didn’t find it :)). Please write the method in some sentence, how I can handle this event, and events like this.

    Thank you!

  6. |

    Hi all,

    I’m newbie withr red5 but I think that this article is more interesting.

    first step. I understand that if you change http.port = 80 you see red5 index page in http://myserver/ and if you have red5/webapps/myapp/streams/video.flv and red5/webapps/myapp/WEB-INF/web.xml with your change, it run in
    rtmp://myserver/myapp/video.flv. it isn’t?

    second step. I would like undertstand if red5 streams a flv video only rtmp://myserver/myapp/video.flv or also, http://myserver/myapp/video.flv.
    is http://myserver/myapp/video.flv url only a dream or is it possible?

    Thank you!

  7. |

    [...] Reference: webmultimediale.org, gregoire.org [...]

  8. |

    [...] followed Mondain’s post to set up Red5 with RTMPT over port 80 and it mostly [...]

  9. |

    [...] Pengaturan konfigurasi port yang digunakan Red5 ini terdapat di file $folder-instalasi-red5/conf/red5.properties, salah satu contoh pengaturan port di Red5 dapat dilihat di http://gregoire.org/2009/01/28/rtmpt-and-red5/ [...]



Leave a Comment


Fatal error: Call to undefined function akismet_counter() in C:\xampp\htdocs\paulgregoireblog\wp-content\themes\googlechrome\footer.php on line 9