Wowza Community

Need to execute some custom business logic for each http request.

Hi Wowza Members,

I want to create a module doing some business logic on each http request. I have wriiten the code below but I’m not getting the desired output.

import java.io.*;

import com.wowza.wms.http.*;

import com.wowza.wms.logging.*;

import com.wowza.wms.vhost.*;

public class ExampleTest extends HTTProvider2Base {

private static final WMSLogger log = WMSLoggerFactory

.getLogger(ExampleTest.class);

public void onHTTPRequest(IVHost vhost, IHTTPRequest req, IHTTPResponse resp) {

log.info(“Some Text” + req.getPath());

log.debug(“Some other text” + req.getPath());

log.error(“Some different text” + req.getPath());

String helloStr = “Hello World!”;

String retStr = “” + helloStr

  • “” + helloStr + “”;

try {

OutputStream out = resp.getOutputStream();

byte[] outBytes = retStr.getBytes();

out.write(outBytes);

} catch (Exception e) {

log.error("ExampleTest: " + e.toString());

}

}

}

I have mentioned the fully qualified name of the class in vHost.xml

com.wowza.wms.example.module.ExampleTest

*

none

After restarting the server i tried to call many http requests but I couldn’t get the desired result.

Kindly provide some assistance to achieve the same

Are you getting any response at all?

Can you post you full HostPortList from the VHost.xml file?

Try using eg. WMSLoggerFactory.getLogger(null).info(“Some Text” + req.getPath());

In these types of question please share VHost.xml file too.


Web Design Walnut Creek | Website Design Dublin, CA

Hi,

This problem suggests your HTTP provider entry is after the last entry which also has

*

As the filter is matched previously, so Filter *, then yours never gets triggered.

As suggested do post the VHost.xml ( or partial for the port you have added it to ) so we can help troubleshoot further.

Andrew.