Module Stop RTMP Dumper connections

We recently saw this posting on the Wowza Media forums

http://www.wowza.com/forums/showthread.php?40722-Foolproof-live-stream-protection

The idea presented was to send information to a client, have it communicate back to Wowza, without this disconnect the client and potentially ban the IP for a period of time.

We looked around for potential clients, writing our own client is very much a no no due to time, and found JWPlayer has an API which could be used just for our purposes. It appeared JWPlayer can provide access to meta data in JavaScript, an example here

http://support.jwplayer.com/customer/portal/articles/1459607-example-using-onmeta-

Using this hook Wowza can send meta data to specific clients and we can then get the client to make HTTP requests back to Wowza.

The JWPlayer code we came up with is as follows

<html>
<head>
<title>JW Player 6</title>
<script type=”text/javascript” src=”/jwplayer/jwplayer.js“></script>
<script type=”text/javascript”>jwplayer.key=”YOURJWPLAYERKEY”</script>
</head>
<body>
<div id=”myElement”>
</div>
<script type=”text/javascript”>
jwplayer(“myElement”).setup({
                         file: “rtmp://192.168.1.2:1935/live/Stream1″
                          });
jwplayer(“myElement”).onMeta(function(event) {
if ( event.metadata.type == “metadata” )
          {
           if ( event.metadata.Name == “UpdateClient” )
                 {
                 var hostL = event.metadata.Host.length;
                 var IDL = event.metadata.IP.length;
                 var IPL = event.metadata.ID.length;
                 //console.log(“length Host is “+hostL+” ID “+IDL+” IP “+IPL);
                 var result = hostL+IDL+IPL;
                 //console.log(“Result is “+result);
                 var destinationIP = event.metadata.DestinationIP;
                 var destinationPort = event.metadata.DestinationPort;
                 var dataString = “”;
                 dataString = “result=”+result;
                 dataString = dataString +”&client=”+event.metadata.ID;
                 dataString = dataString +”&application=”+event.metadata.Application;
                 dataString = dataString +”&applicationinstance=”+event.metadata.AppInstance;
                 //console.log(“Datatring is ‘”+dataString+”‘”);
                 var URL = “http://”+destinationIP+”:”+destinationPort+”/sessionvalidator?”+dataString;
                 //console.log(“URL is “+URL);
                 var request = new XMLHttpRequest();
                 request.open(“GET”, URL, true);
                 request.send(“”);
                 }
        }
});
</script>
</body>
</html>

So that is the simple player, normal player set up, with a meta data handler to receive data from Wowza and then make HTTP requests back to Wowza. The Javascript calculates a result based on Host, IP and ID sent over in the meta data from Wowza. This is a basic example of a calculation which you can change for your implementation. Wowza has also stored this calculated value against the client it has sent the meta data to.

Now when the Java script sends the value back to Wowza it can compare what it has and if the two match it resets the disconnect timer to the client.

In order to implement the Wowza side you need to add a Module to your application with the following parameters. It is important ALL these are correct.

Name – Interaction
Description – Interaction
Class – guru.thewowza.example.player.Interaction

In the module code there is a class called ClientCheckAndRemove this contains the function generateClientResult. This function performs the same calculation as the Javascript so if you modify one, you MUST modify the other.

You also need to add a HTTP Provider to your VHost with the following parameters

BaseClass – guru.thewowza.example.player.HTTPValidator
RequestFilters – sessionvalidator*
AuthenticationMethod – none

This entry needs to go before the RequestFilter of * otherwise it will not work.

Source code is provided in the download and also a pre-compiled JAR that you can test with. Do be aware this is purely proof of concept code and although should work it will have limited success. We would recommend at least making the calculation include a random number and minifying the javascript to make it less visible.

TWGPlayerInteraction Source Code & Examples


Comments are closed.