Wowza Community

How to access configuration from server listener (IServerNotify2)?

Hello,

trying to access configuration in server listeners methods:

onServerConfigLoaded(IServer server) and onServerCreate(IServer server)

server.getProperties().get(‘key’) gives me null;

server.getProperties().getAllAsStrings() and iterating over result gives me null pointer exception;

same with getManagerProperties().

server.getConfig(path) gives me whole xml as a string (??)

wowzaStreamingEngine 4.0.1

How can i access properties from Server.xml config?

  • bonus question: how to access applications configs from this server listener ?

solved by creating app instance on server startup. Will it create some additional problems?

private WMSProperties getAppConfig(String appName, String vhostName) {
    IVHost vhost = VHostSingleton.getInstance(vhostName, true) ;
    Application app = new Application(appName, vhost);
    IApplicationInstance appi = app.getAppInstance(appName);
    return appi.getProperties();
}

Hi,

You can get and set properties like this:

server.getProperties().getPropertyStr("key");
		
server.getProperties().setProperty("key", "someKey");

This does not write to files, it is only in memory. You can do the same with most other objects in Wowza as well.

Richard

solved by creating app instance on server startup. Will it create some additional problems?

private WMSProperties getAppConfig(String appName, String vhostName) {
    IVHost vhost = VHostSingleton.getInstance(vhostName, true) ;
    Application app = new Application(appName, vhost);
    IApplicationInstance appi = app.getAppInstance(appName);
    return appi.getProperties();
}

Hi,

This method will work if you are just reading properties that are set in the Application.xml however, you wont be able to modify any ans you application has not been fully started.

You should use

IApplication app = vhost.getApplication(appName);

This will start the application properly.

Roger.