msgbartop
Various ramblings-on, mostly about Red5
msgbarbottom

03 Jun 09 Multiple HTTP socket configurations

Red5 version 0.8.0 introduces the ability to bind multiple ports and hosts for HTTP access; starting at revision 3632. Previously there were other options to accomplish this feature, but now it is built-in. So I’ll get right to it. The older configuration style for the tomcat server bean was like so:

<bean id="tomcat.server" class="org.red5.server.tomcat.TomcatLoader" init-method="init" destroy-method="shutdown" depends-on="context.loader">
	<property name="webappFolder" value="${red5.root}/webapps" />
	<property name="connector">
		<bean class="org.apache.catalina.connector.Connector">
			<constructor -arg type="java.lang.String" value="org.apache.coyote.http11.Http11NioProtocol" />	
			<property name="port"><value>${http.port}</value></property>
			<property name="redirectPort"><value>${https.port}</value></property>
			<property name="enableLookups"><value>false</value></property>
		</bean>
	</property>
	<property name="baseHost">
		<bean class="org.apache.catalina.core.StandardHost">
			<property name="name" value="${http.host}" />
			<property name="unpackWARs" value="true" />
			<property name="autoDeploy" value="true" />
			<property name="xmlValidation" value="false" />
			<property name="xmlNamespaceAware" value="false" />
		</bean>	   
	</property>	
</bean>

This allowed for one connector (port) and one host (like www.red5.org). If http.host were set to “192.168.0.1” and http.port was set to “5080”, then you would be able to connect to “http://192.168.0.1:5080/” in your browser.
This latest configuration still supports this configuration, but allows for much more.

<bean id="tomcat.server" class="org.red5.server.tomcat.TomcatLoader" init-method="init" destroy-method="shutdown" depends-on="context.loader">
	<property name="webappFolder" value="${red5.root}/webapps" />
	<property name="connectors">
		<list>
			<bean id="defaultHttp" class="org.apache.catalina.connector.Connector">
				<constructor -arg type="java.lang.String" value="org.apache.coyote.http11.Http11NioProtocol" />	
				<property name="port"><value>${http.host}</value></property>
				<property name="redirectPort"><value>8080</value></property>
				<property name="enableLookups"><value>false</value></property>
			</bean>
			<bean id="defaultProxy" class="org.apache.catalina.connector.Connector">
				<constructor -arg type="java.lang.String" value="org.apache.coyote.http11.Http11NioProtocol" />	
				<property name="port"><value>8080</value></property>
				<property name="redirectPort"><value>${https.port}</value></property>
				<property name="enableLookups"><value>false</value></property>
			</bean>
		</list>
	</property>	
	<property name="baseHost">
		<bean class="org.apache.catalina.core.StandardHost">
			<property name="name" value="${http.host}" />
			<property name="unpackWARs" value="true" />
			<property name="autoDeploy" value="true" />
			<property name="xmlValidation" value="false" />
			<property name="xmlNamespaceAware" value="false" />
		</bean>	   
	</property>	
	<property name="hosts">
		<list>
			<bean id="local2" class="org.apache.catalina.core.StandardHost">
				<property name="name" value="192.168.0.2" />
				<property name="autoDeploy" value="false" />
				<property name="xmlValidation" value="false" />
				<property name="xmlNamespaceAware" value="false" />
			</bean>	   
			<bean id="local3" class="org.apache.catalina.core.StandardHost">
				<property name="name" value="10.0.0.2" />
				<property name="autoDeploy" value="false" />
				<property name="xmlValidation" value="false" />
				<property name="xmlNamespaceAware" value="false" />
			</bean>	   
		</list>
	</property>
</bean>

This allows for two connector (ports on each host) and three hosts. If http.host were set to “192.168.0.1” and http.port was set to “5080”, then you would be able to connect to “http://192.168.0.1:5080/” in your browser. In addition you would also have these urls available:

  • http://192.168.0.1:8080/
  • http://192.168.0.2:5080/
  • http://192.168.0.2:8080/
  • http://10.0.0.2:5080/
  • http://10.0.0.2:8080/

Each application (context) within your red5/webapps directory is made available on each host as well.
Lastly, the “host” name does not have to be an IP address; you can specify a valid dns host name instead.

Tags: , , , ,

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: , , , , , , ,

28 Sep 08 Tomcat connectors

In Red5, you have pretty much full access to manipulate the embedded Tomcat engine via Spring. With that being said I would like to give details on how to change the http connector between two available options; there are several other options, but I’ll only be covering NIO and BIO. First a quick explanation of these two options:

  • BIO – Blocking Input / Output, this has been around since the beginning of internet time. It uses one thread per socket connnection to handle requests.
  • NIO – Non-blocking Input / Output, this has been available in the JDK since 1.4. It uses a single thread to handle many socket connections.
In most cases, you should find NIO to be much faster and more able to handle a lot more connections than BIO will. The default connector was set to NIO until today when I switched it to BIO to prevent problems with Unix-based systems (OSX / Linux).
The configuration of Tomcat in Red5 for HTTP, RTMPT, and RTMPS is nearly identical so you may apply the configuration items below to any of the embedded servers. To configure with a BIO connector, locate the connector section and change the constructor arg value:

<property name=”connector”>
  <bean class=”org.apache.catalina.connector.Connector”>
    <constructor-arg type=”java.lang.String” value=”org.apache.coyote.http11.Http11Protocol” />
    <property name=”port”><value>80</value></property>
    <property name=”redirectPort”><value>443</value></property>
    <property name=”enableLookups”><value>false</value></property>
  </bean>
</property>

To use the NIO connector simply change the constructor arg as shown below:

<property name=”connector”>
  <bean class=”org.apache.catalina.connector.Connector”>
    <constructor-arg type=”java.lang.String” value=”org.apache.coyote.http11.Http11NioProtocol” />
    <property name=”port”><value>80</value></property>
    <property name=”redirectPort”><value>443</value></property>
    <property name=”enableLookups”><value>false</value></property>
  </bean>
</property>

Tags: , , , , , , , ,


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