servletsred5http-tunneling

How do I tunnel Red5 through http without getting NetConnection.Connect.Closed error?


Red5 v0.8

I'm trying to tunnel red5 through port 80, since my application doesn't work on certain setups.

At first I tried just putting ":80" right after the domain name when I make my red5 connections. That resulted in a new NetConnection.Connect.Closed error.

Then I reversed those changes, then tried following this guide I found and after implementing the changes, I get the same error.

So what am I doing wrong/what more do I need to do?

Also, what code/config files should I provide you with?

EDIT:

So I looked in the Red5 logs, and it seems that I get this

2013-06-14 05:04:53,330 [main] ERROR o.a.coyote.http11.Http11Protocol - Error initializing endpoint
java.net.BindException: Address already in use<null>:80

The full error message is below.

I did a 'netstat -nlp' and saw that 'nginx' is on port 80, so this might possibly be a problem.

Then again, 'nginx' is a http server, so it doesn't make much sense to move the http away from http


My web.xml, as referenced in the guide, contains this:

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

And in red5/conf/red5.properties, I have the following:

# HTTP
http.host=0.0.0.0
http.port=80
https.port=8443

Error message from logs

java.net.BindException: Address already in use<null>:80
    at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:502) [tomcat-coyote-6.0.18.jar:na]
    at org.apache.coyote.http11.Http11Protocol.init(Http11Protocol.java:176) [tomcat-coyote-6.0.18.jar:na]
    at org.apache.catalina.connector.Connector.initialize(Connector.java:1058) [catalina-6.0.18.jar:na]
    at org.apache.catalina.startup.Embedded.start(Embedded.java:830) [catalina-6.0.18.jar:na]
    at org.red5.server.tomcat.TomcatLoader.init(TomcatLoader.java:430) [red5.jar:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [na:1.6.0_27]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [na:1.6.0_27]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [na:1.6.0_27]
    at java.lang.reflect.Method.invoke(Method.java:616) [na:1.6.0_27]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1414) [spring-beans-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1375) [spring-beans-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335) [spring-beans-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) [spring-beans-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) [spring-beans-2.5.6.jar:2.5.6]
    at java.security.AccessController.doPrivileged(Native Method) [na:1.6.0_27]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) [spring-beans-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) [spring-beans-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [spring-beans-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) [spring-beans-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) [spring-beans-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) [spring-beans-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429) [spring-beans-2.5.6.jar:2.5.6]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728) [spring-context-2.5.6.jar:2.5.6]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380) [spring-context-2.5.6.jar:2.5.6]
    at org.red5.server.Launcher.launch(Launcher.java:60) [red5.jar:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [na:1.6.0_27]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [na:1.6.0_27]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [na:1.6.0_27]
    at java.lang.reflect.Method.invoke(Method.java:616) [na:1.6.0_27]
    at org.red5.server.Bootstrap.bootStrap(Bootstrap.java:106) [boot.jar:na]
    at org.red5.server.Bootstrap.main(Bootstrap.java:50) [boot.jar:na]

Solution

  • You cannot let the red5 server AND a http server both listen on port 80 simultaneously. To use RTMPT, you can use a proxy server to redirect the open/send/fsc/idle etc. requests to the local red5 server on e.g. port 5080. This is the configuration I use in my apache web server:

    ProxyPass /open http://localhost:5080/open
    ProxyPassReverse /open http://localhost:5080/open
    ProxyPass /send http://localhost:5080/send
    ProxyPassReverse /send http://localhost:5080/send
    ProxyPass /idle http://localhost:5080/idle
    ProxyPassReverse /idle http://localhost:5080/idle
    ProxyPass /close http://localhost:5080/close
    ProxyPassReverse /close http://localhost:5080/close
    ProxyPass /fcs http://localhost:5080/fcs
    ProxyPassReverse /fcs http://localhost:5080/fcs
    

    and let the red5 server listen on port 5080 which is the default:

    # HTTP
    http.host=0.0.0.0
    http.port=5080
    https.port=5443
    

    but of course you can use any other unused port if you like.