Display current listeners using PHP

How I can create a PHP script to see these statistics without authentication bypass?

Hi, Thanks for the reply,

I’m trying to create an interface to display real time statistics to my client, I can not disable authentication and tried with different authentication methods of PHP like Curl, HttpRequest, file_get_contents and simplexml_load_file, but always returns this error:

“failed to open stream: HTTP request failed! HTTP/1.0 401 Unauthorized in …”

I do not know why my authentication is not validated…

For example, I trying with:

<?php $page = file_get_contents('http://myuser:mypassword@myservername:myport/connectioncounts'); echo $page; ?>

Thanks for the prompt response,

I am using port 8086.

I have not even changed the file VHost.xml.

However through my browser I can to access the statistics using the URL:

http://myuser:mypassword@MyServerName:MYPORT/connectioncounts

Thanks for your help…

For your method to work, you have to change the /conf/VHost.xml HTTProvider /AuthenticationMethod from “admin-digest” to “admin-basic” or “none”

<HTTPProvider>
	<BaseClass>com.wowza.wms.http.HTTPConnectionCountsXML</BaseClass>
	<RequestFilters>connectioncounts*</RequestFilters>
	<AuthenticationMethod>admin-basic</AuthenticationMethod>
</HTTPProvider>

Then restart Wowza.

Richard

I am having trouble calling [ip]:8086/connectioncounts from any web application. I am able to call it from a browser without an issue.

I have tried the php example and a coldfusion example still I am not able to call the xml file. I can however I can call [ip]:1935/clientaccesspolicy.xml without a problem.

I am on an EC2 machine and have port 8086 and 1935 configured the same way. Any help would be appreciated. Thanks.

Probably because clientaccesspolicy doesn’t require authentication. Where you able to turn off authentication so you can access connection counts without the password prompt? Remember, if you put in your credentials in your browser one time, it doesn’t ask you again until you restart Wowza.

I posted a Perl script here to get connectioncounts: https://www.wowza.com/forums/showthread.php?15165-get-connectioncounts-from-perl-for-accumulation

Hi Randal,

Thanks for the reply. I have conf/vhost.xml set as below

					<HTTPProvider>
						<BaseClass>com.wowza.wms.http.HTTPConnectionCountsXML</BaseClass>
						<RequestFilters>connectioncounts*</RequestFilters>
						<AuthenticationMethod>none</AuthenticationMethod>
					</HTTPProvider>

and can confirm from multiple devices that from the browser i do not have to input username and password to access.

I have tried the php, perl and coldfusion code and the response I get is timeouts of (php)“Maximum execution time of 45 seconds exceeded” and (cf)“Connection Failure”

I feel like I am missing something fundamental here but cannot figure it out. Thanks for the help.

Hi…Solved.

Come to find out my host was blocking port 8086. So I changed the port in vhost and now all is well.

Hello All

Need help trying to return Stats for a single application under 1 VHOST

Here’s a step by step process to get stats with basic authentication WITH php code to answer the original question:

  1. In your wowza install in conf/Vhost.xml change the values of admin-digest to admin-basic for whatever HTTPProvider you want to authenticate for. I changed them all to “basic” because I need to report for everything available.

  2. Use this PHP code to test for your server

<?php header("Content-type: text/xml; charset=utf-8"); // username and password for reporting are created in Wowzainstall/conf/admin.password $wowzaurl = "http://localhost:8086/connectioncounts"; $username = "username"; $password = "password"; //header wowza expects for basic authentication - base 64 encoded. $context = stream_context_create(array( 'http' => array( 'header' => "Authorization: Basic " . base64_encode("".$username.":".$password."") ) )); //get contents with sending the special header into an xml file $WowzaMediaServer = simplexml_load_string(file_get_contents($wowzaurl,false,$context)); //print XML result print_r($WowzaMediaServer); exit; ?>