Various ramblings-on, mostly about Red5

07 Aug 09 How to add an IoFilter per Application or Server

A new feature has been added to Red5 to allow any number of Mina IoFilters to be added to a connection at the Server or Application level. The particular filter detailed here is one that simply counts the connections and rejects any that exceed the set maximum number. This post details setting the filter at the Application level, but if you want it at the server level simply add the below bean definitions to your global webapp configuration located here: red5/webapps/red5-default.xml.

To add the filter you must first edit your applications red5-web.xml and add your beans:

<!-- Limits connections on a per-session basis -->
<bean id="connectionFilter" class="org.gregoire.red5.ConnectionShapeFilter">
    <property name="maxConnections" value="2"/>

Next create a “config” bean to inform the server about your filter bean names:

<bean id="config" class="org.red5.server.adapter.Config">
    <!-- List of filter bean names to be loaded -->
    <property name="filterNames">

One important thing to note is that since classes in the main server are creating the connections, your filter classes must be found by the URLClassloader. The URLClassloader created by the server uses jar files within Red5’s lib directory, so put your filter classes here (red5/lib) inside a jar. Once your classes are in-place, start your server and the filters will take effect.

An example Eclipse / FlexBuilder project can be found here.

Tags: , , ,

Reader's Comments

  1. |

    Dear Sir,

    Sorry to ask a newbies question here but Is there a way to limit a size of publish/record file with red5?


  2. |

    This is something you would have to write yourself, there isn’t anything that I know of that you could use for this right now. This is part of the beauty of the system, you can make it do what ever you want.

  3. |


    First of all – thanks for making red5 exist! It’s awesome :)

    Now, I’m not a Java dev, so this might be a completely noob sounding question, but where do I get the JAR file for org.gregoire.red5.ConnectionShapeFilter ? Is it something I can just download an put in the red5/lib folder or do I have to get the source and do some compiling?



  4. |

    I try to use this code to limit users with oflademo but i can’t make it working.
    How can i use it with oflademo in eclipse?

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