# HTTProvider that returns detail server info

**URL:** <https://community.wowza.com/t/httprovider-that-returns-detail-server-info/77>\
**Category:** Wowza Streaming Engine\
**Created:** [August 24, 2009, 3:48pm UTC](https://community.wowza.com/t/httprovider-that-returns-detail-server-info/77 "2009-08-24T15:48:42Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/system/32/447_2.png) [@system](https://community.wowza.com/u/system)\
**Post date:** [August 24, 2009, 3:48pm UTC](https://community.wowza.com/t/httprovider-that-returns-detail-server-info/77/1 "2009-08-24T15:48:42Z")

</div>

An **HTTPProvider** is an extension to the server that can be attached to a **HostPort** definition in **[install-dir]/conf/VHost.xml** and can be used to return HTTP data quickly from the server using a web browser or automated tool. There is more detailed information on this subject in the User’s Guide. The class below is an HTTPProvider that returns detail server information.

```auto
package com.mycompany.wms.http;
import java.io.*;
import java.util.*;
import com.wowza.wms.vhost.*;
import com.wowza.wms.logging.WMSLoggerFactory;
import com.wowza.wms.server.*;
import com.wowza.wms.application.*;
import com.wowza.wms.http.*;
import com.wowza.wms.client.*;
public class HTTPServerInfoXML implements IHTTPProvider
{
	private WMSProperties properties = null;
	private HTTPCrossdomainHandler crossdomainHandler = new HTTPCrossdomainHandler();
	
	public void onBind(IVHost vhost, HostPort hostPort)
	{
		crossdomainHandler.setVHost(vhost);
	}
	public void onUnbind(IVHost vhost, HostPort hostPort)
	{
	}
	
	public void setProperties(WMSProperties properties)
	{
		this.properties = properties;
		crossdomainHandler.setProperties(properties);
	}
	
	private void outputConnectionInfo(StringBuffer ret, ConnectionCounter counter)
	{
		ret.append("<ConnectionsCurrent>"+counter.getCurrent()+"</ConnectionsCurrent>");
		ret.append("<ConnectionsTotal>"+counter.getTotal()+"</ConnectionsTotal>");
		ret.append("<ConnectionsTotalAccepted>"+counter.getTotalAccepted()+"</ConnectionsTotalAccepted>");
		ret.append("<ConnectionsTotalRejected>"+counter.getTotalRejected()+"</ConnectionsTotalRejected>");
	}
	
	public void onHTTPRequest(IVHost inVhost, IHTTPRequest req, IHTTPResponse resp)
	{
		if (crossdomainHandler.handleCrossdomainRequest(inVhost, req, resp))
			return;
		StringBuffer ret = new StringBuffer();
		
		try
		{
			List vhostNames = VHostSingleton.getVHostNames();
			ret.append("<?xml version=\"1.0\"?>\n<WowzaMediaServerPro>");
					
			Iterator<String> iter = vhostNames.iterator();
			while (iter.hasNext())
			{
				String vhostName = iter.next();
				IVHost vhost = (IVHost)VHostSingleton.getInstance(vhostName);
				if (vhost != null)
				{
					ret.append("<VHost>");
					ret.append("<Name>"+vhostName+"</Name>");
					ret.append("<TimeRunning>"+vhost.getTimeRunningSeconds()+"</TimeRunning>");
					ret.append("<ConnectionsLimit>"+vhost.getConnectionLimit()+"</ConnectionsLimit>");
					
					outputConnectionInfo(ret, vhost.getConnectionCounter());
					
					List appNames = vhost.getApplicationNames();
					List<String> appFolders = vhost.getApplicationFolderNames();
					Iterator<String> appNameIterator = appFolders.iterator();
					while (appNameIterator.hasNext())
					{
						String applicationName = appNameIterator.next();
						ret.append("<Application>");
						ret.append("<Name><![CDATA["+applicationName+"]]></Name>");
						boolean appExists = appNames.contains(applicationName);
						ret.append("<Status>"+(appExists?"loaded":"unloaded")+"</Status>");
						if (appExists)
						{
							IApplication application = vhost.getApplication(applicationName);
							ret.append("<TimeRunning>"+application.getTimeRunningSeconds()+"</TimeRunning>");
							outputConnectionInfo(ret, application.getConnectionCounter());
							
							List appInstances = application.getAppInstanceNames();
							Iterator<String> iterAppInstances = appInstances.iterator();
							while (iterAppInstances.hasNext())
							{
								String appInstanceName = iterAppInstances.next();
								IApplicationInstance appInstance = application.getAppInstance(appInstanceName);
								if (appInstance == null)
									continue;
								
								ret.append("<ApplicationInstance>");
								ret.append("<Name><![CDATA["+appInstance.getName()+"]]></Name>");
								ret.append("<TimeRunning>"+appInstance.getTimeRunningSeconds()+"</TimeRunning>");
								
								outputConnectionInfo(ret, appInstance.getConnectionCounter());
								
								int count = appInstance.getClientCount();
								for(int c=0;c<count;c++)
								{
									IClient client = appInstance.getClient(c);
									if (client == null)
										continue;
									ret.append("<Client>");
									ret.append("<ClientId>"+client.getClientId()+"</ClientId>");
									ret.append("<FlashVersion>"+client.getFlashVer()+"</FlashVersion>");
									ret.append("<IpAddress>"+client.getIp()+"</IpAddress>");
									ret.append("<Referrer><![CDATA["+client.getReferrer()+"]]></Referrer>");
									ret.append("<TimeRunning>"+client.getTimeRunningSeconds()+"</TimeRunning>");
									//ret.append("<Duration>"+((double)(System.currentTimeMillis()-client.getConnectTime())/1000.0)+"</Duration>");
									ret.append("<DateStarted>"+client.getDateStarted()+"</DateStarted>");
									ret.append("<URI><![CDATA["+client.getUri()+"]]></URI>");
									
									String protocolStr = "unknown";
									switch(client.getProtocol())
									{
									case RtmpSessionInfo.PROTOCOL_RTMP:
										protocolStr = client.isEncrypted()?"RTMPE":"RTMP";
										break;
									case RtmpSessionInfo.PROTOCOL_RTMPT:
										protocolStr = client.isSSL()?"RTMPS":(client.isEncrypted()?"RTMPTE":"RTMPT");
										break;
									}
									
									ret.append("<Protocol>"+protocolStr+"</Protocol>");
									ret.append("<IsSSL>"+client.isSSL()+"</IsSSL>");
									ret.append("<IsEncrypted>"+client.isEncrypted()+"</IsEncrypted>");
									ret.append("<Port>"+client.getServerHostPort().getPort()+"</Port>");
									ret.append("</Client>");
								}
								
								ret.append("</ApplicationInstance>");
							}
						}
						
						ret.append("</Application>");
					}
					
					ret.append("</VHost>");
				}
			}
			
			ret.append("</WowzaMediaServerPro>");
		}
		catch (Exception e)
		{
			WMSLoggerFactory.getLogger(HTTPServerVersion.class).error("HTTPServerInfoXML.onHTTPRequest: "+e.toString());
			e.printStackTrace();
		}
				
		try
		{
			resp.setHeader("Content-Type", "text/xml");
			
			OutputStream out = resp.getOutputStream();
			byte[] outBytes = ret.toString().getBytes();
			out.write(outBytes);
		}
		catch (Exception e)
		{
			WMSLoggerFactory.getLogger(HTTPServerVersion.class).error("HTTPServerInfoXML.onHTTPRequest: "+e.toString());
			e.printStackTrace();
		}
	}
}

```

Use the **Wowza IDE** to compile this class into a jar file and copy it to the **[install-dir]/lib** folder. To use it, edit **[install-dir]/conf/VHost.xml** and change the **HostPort/HTTPProvider/BaseClass** to the full path to this class **com.mycompany.wms.http.HTTPServerInfoXML**.

Charlie

---

<div class="post-metadata">

**Author:** ![Y\_Sun](https://avatars.discourse-cdn.com/v4/letter/y/958977/32.png) [@Y\_Sun](https://community.wowza.com/u/Y_Sun)\
**Post date:** [August 25, 2009, 2:46am UTC](https://community.wowza.com/t/httprovider-that-returns-detail-server-info/77/2 "2009-08-25T02:46:12Z")

</div>

I’m getting ClassNotFoundException error.

…

error parsing HTTPProvider properties: java.lang.ClassNotFoundException: com.test.HTTPServerInfoXML

com.test.HTTPServerInfoXML

…

how do i verify the classpath?

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [August 25, 2009, 11:01am UTC](https://community.wowza.com/t/httprovider-that-returns-detail-server-info/77/3 "2009-08-25T11:01:38Z")

</div>

If you compiled as is, it will be:

> com.mycompany.wms.http.HTTPServerInfoXML

> package.ClassName

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [November 6, 2009, 11:49am UTC](https://community.wowza.com/t/httprovider-that-returns-detail-server-info/77/4 "2009-11-06T11:49:45Z")

</div>

Thomas,

With Wowza Server 2 Advanced you can define as many HTTPProviders as you want using “RequestFilters”:

> com.wowza.wms.http.HTTPServerInfoXML
> 
> \*serverinfoxml
> 
> none
> 
> com.wowza.wms.http.HTTPConnectionCountsXML
> 
> \*connectioncounts.xml
> 
> none

You can get Wowza Server 2 Advanced here:

[http://wowza.com/advanced](http://wowza.com/advanced)

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [November 6, 2009, 11:54am UTC](https://community.wowza.com/t/httprovider-that-returns-detail-server-info/77/5 "2009-11-06T11:54:50Z")

</div>

Also, with Wowza 1.7.2 you could do it by creating new HostPort/s using other ports, just for its HTTPProvider.

> 4
> 
> \*
> 
> 8080
> 
> true
> 
> 24000
> 
> 65000
> 
> true
> 
> 100
> 
> com.wowza.wms.http.YourHTTPProvider

Richard

---

<div class="post-metadata">

**Author:** ![Sebastien\_Faure](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@Sebastien\_Faure](https://community.wowza.com/u/Sebastien_Faure)\
**Post date:** [September 2, 2009, 5:20pm UTC](https://community.wowza.com/t/httprovider-that-returns-detail-server-info/77/6 "2009-09-02T17:20:38Z")

</div>

Works here too, thanks Charlie …

---

<div class="post-metadata">

**Author:** ![Y\_Sun](https://avatars.discourse-cdn.com/v4/letter/y/958977/32.png) [@Y\_Sun](https://community.wowza.com/u/Y_Sun)\
**Post date:** [August 25, 2009, 3:08am UTC](https://community.wowza.com/t/httprovider-that-returns-detail-server-info/77/7 "2009-08-25T03:08:48Z")

</div>

I got it working. Realized that it is a problem in my jar file (corrupted).

---

<div class="post-metadata">

**Author:** ![aze\_aze](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@aze\_aze](https://community.wowza.com/u/aze_aze)\
**Post date:** [November 5, 2009, 1:05pm UTC](https://community.wowza.com/t/httprovider-that-returns-detail-server-info/77/8 "2009-11-05T13:05:14Z")

</div>

Exactly what I was looking for. Richard pointed me to this thread 🙂

---

<div class="post-metadata">

**Author:** ![aze\_aze](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@aze\_aze](https://community.wowza.com/u/aze_aze)\
**Post date:** [November 6, 2009, 2:19am UTC](https://community.wowza.com/t/httprovider-that-returns-detail-server-info/77/9 "2009-11-06T02:19:06Z")

</div>

It works well, but let’s say I’d like to have different http servlets running. How to map each servlet to a url? Currently I can only have 1 httpprovider no matter which url I input, it always hits the same provider.

---

<div class="post-metadata">

**Author:** ![aze\_aze](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@aze\_aze](https://community.wowza.com/u/aze_aze)\
**Post date:** [November 6, 2009, 4:31am UTC](https://community.wowza.com/t/httprovider-that-returns-detail-server-info/77/10 "2009-11-06T04:31:09Z")

</div>

Hmmm… That’s not very pretty, but yeah it does the trick, as it is used only internally by my server. Thank your Richard 🆒
