Wowza Community

VHost.getApplication() freezes module when called in HTTPProvider

Hi,

I’m having an issue with my HTTPProvider. I’ve setup a HTTPProvider to communicate between applications. In the client module I do a request to the HTTPProvider in the onAppStart. For testing purposes this is done on the same server. When the HTTPProvider.onHTTPRequest is called and tries to get the application from the vHost wowza freezes. If I wrap the http request in a TimerTask and perform it 1ms later, everything is fine. Any suggestions how to make sure I can get the application without using ugly timers?

Data Module

public void onAppStart(IApplicationInstance appInstance) 
{
	super.onAppStart( appInstance );
	String response = null;
	String method= "test";
	byte[] resp = HTTPUtils.HTTPRequestToByteArray( "http://localhost:8086/olsa-streamer/"+_module.getSeminarId()+"/"+method, "POST", null, null );
	try {
		response = new String( resp, "UTF-8" );
		JSONObject jsonResponse = new JSONObject( response );
		return OLSAStreamerResponse.fromJSON(jsonResponse);
	} catch (UnsupportedEncodingException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} catch (JSONException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}

HTTPProvider

public void onHTTPRequest( IVHost inVhost, IHTTPRequest req, IHTTPResponse resp ) 
{
	String appName = "olsa-streamer";
	log.info( "has app " +appName+" "+Boolean.toString( inVhost.applicationExists( appName ) ) );
	IApplication application = inVhost.getApplication( appName );
	log.info( "fetched app " +appName );
}

In this scenario the application reference will be locked (WMSReadWriteLock) and will prevent you from accessing it in this manner. You would have to create a thread to execute after the release of the lock (probably why your 1ms thread works). You might possible consider a later event i.e. onConnect etc.