Results 1 to 2 of 2

Thread: Dynamic Loadbalancer - PHP script for iOS load balancing

  1. #1
    Join Date
    Mar 2012
    Posts
    3

    Default Dynamic Loadbalancer - PHP script for iOS load balancing

    My first post here - so hi, I'm Philipp and I come from (-> username) Munich in Germany.
    I setup Wowza on EC2 with the Dynamic Loadbalancing Module. This works just fine with any compatible flash player like JWPLayer. But I was not able to find a way on how to get loadbalancing to work with iOS clients.
    So I went and wrote some php (my first .php script actually, so please enhance it as needed and let me know what you did):

    Code:
    <?php
    // CONFIG START - Input in your Wowza Dynamic Loadbalancers address, your application's name and the streamname
     $lburl = "http://url-or-ip-of-lb-instance:1935/loadbalancer";
     $appname = "liveedge";
     $streamname = "myStream";
    // Config END
    
    $content = file_get_contents ($lburl);
    $replacewith = "";
    $ip = str_replace('redirect=', $replacewith, $content);
    header("Cache-Control: no-cache, must-revalidate");
    header("Location:http://$ip/$appname/$streamname/playlist.m3u8");
    ?>
    I guess it is pretty self-explanatory, it connects to the loadbalancer URL and gets the output (least loaded server). Then it removes the string "redirect=" and puts together a 302 redirect.

    So if you open the .php file from your ios device it will work just fine.
    To be on the safe side I would recommend to call the file playlist.m3u8 and add an Apache Directive to the server hosting the .php:
    Code:
    AddType application/x-httpd-php .m3u8
    Of course you should only do this if you dont plan to deliver real .m3u8 files using the same apache VHost - I recommend using a dedicated VHost for this.

    So when you configure your player to use:
    Code:
    http://apachehost-ios-lb.example.com/playlist.m3u8
    it actually calls the .php script and gets redirected to:
    Code:
    http://least-used-server/appname/streamname/playlist.m3u8
    Tested with iOS and Quicktime for Mac

    I hope this is useful for some of you!

  2. #2
    Join Date
    Mar 2012
    Posts
    3

    Default

    Sorry, wrong forum. Although this should also work with Wowza 2.x please head over to: http://www.wowza.com/forums/showthread.php?17319 if you have any comments/remarks/questions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •