# Display current listeners using PHP

**URL:** <https://community.wowza.com/t/display-current-listeners-using-php/34372>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api\
**Created:** [March 3, 2010, 6:23pm UTC](https://community.wowza.com/t/display-current-listeners-using-php/34372 "2010-03-03T18:23:20Z")\
**Posts on this page:** 8\
**Page:** 3

<div class="post-metadata">

**Author:** ![Jhonathan\_Espinosa](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@Jhonathan\_Espinosa](https://community.wowza.com/u/Jhonathan_Espinosa)\
**Post date:** [October 24, 2011, 5:11pm UTC](https://community.wowza.com/t/display-current-listeners-using-php/34372/41 "2011-10-24T17:11:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jhonathan\_Espinosa](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@Jhonathan\_Espinosa](https://community.wowza.com/u/Jhonathan_Espinosa)\
**Post date:** [October 25, 2011, 12:59pm UTC](https://community.wowza.com/t/display-current-listeners-using-php/34372/42 "2011-10-25T12:59:15Z")

</div>

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; ?\>

---

<div class="post-metadata">

**Author:** ![Jhonathan\_Espinosa](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@Jhonathan\_Espinosa](https://community.wowza.com/u/Jhonathan_Espinosa)\
**Post date:** [October 25, 2011, 3:45pm UTC](https://community.wowza.com/t/display-current-listeners-using-php/34372/43 "2011-10-25T15:45:07Z")

</div>

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](http://myuser:mypassword@MyServerName:MYPORT/connectioncounts)

Thanks for your help…

---

<div class="post-metadata">

**Author:** ![Phil\_Smith](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@Phil\_Smith](https://community.wowza.com/u/Phil_Smith)\
**Post date:** [March 22, 2012, 8:11pm UTC](https://community.wowza.com/t/display-current-listeners-using-php/34372/44 "2012-03-22T20:11:31Z")

</div>

> For your method to work, you have to change the /conf/VHost.xml HTTProvider /AuthenticationMethod from “admin-digest” to “admin-basic” or “none”
> 
> ```auto
> <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.

---

<div class="post-metadata">

**Author:** ![Phil\_Smith](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@Phil\_Smith](https://community.wowza.com/u/Phil_Smith)\
**Post date:** [March 23, 2012, 6:10am UTC](https://community.wowza.com/t/display-current-listeners-using-php/34372/45 "2012-03-23T06:10:14Z")

</div>

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

```auto
					<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.

---

<div class="post-metadata">

**Author:** ![Phil\_Smith](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@Phil\_Smith](https://community.wowza.com/u/Phil_Smith)\
**Post date:** [March 23, 2012, 9:03pm UTC](https://community.wowza.com/t/display-current-listeners-using-php/34372/46 "2012-03-23T21:03:32Z")

</div>

Hi…Solved.

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

---

<div class="post-metadata">

**Author:** ![Marvin\_Skeete](https://avatars.discourse-cdn.com/v4/letter/m/3be4f8/32.png) [@Marvin\_Skeete](https://community.wowza.com/u/Marvin_Skeete)\
**Post date:** [September 10, 2012, 3:46pm UTC](https://community.wowza.com/t/display-current-listeners-using-php/34372/47 "2012-09-10T15:46:17Z")

</div>

Hello All

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

---

<div class="post-metadata">

**Author:** ![anon\_anon](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@anon\_anon](https://community.wowza.com/u/anon_anon)\
**Post date:** [March 13, 2013, 1:45pm UTC](https://community.wowza.com/t/display-current-listeners-using-php/34372/48 "2013-03-13T13:45:40Z")

</div>

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; ?\>

[Previous page](https://community.wowza.com/t/display-current-listeners-using-php/34372.md?page=2)
