set Properties in the Application.xml

Hello

I am creating a module to add the following property in application.xml

<Property>
	<Name>secureurlparams.publish</Name>
	<Value>12345.doPublish</Value>
</Property>

can anyone provide a module code to update secure URL param’s property in application.xml.

This module should execute every time user starts streaming.

My plan is when user creates stream I will store these params in database and every time user starts streaming I want to retrieve these params and update in application.xml.

Please help if you have better solution.

Thanks

It’s not too very easy to actually update the Application.xml however it is very simple to update the property internally in Wowza. If the application stops it will revert back to the Application.xml entry. If you are wanting to write some values out when the application stops then look at the

public void onAppStop(IApplicationInstance appInstance) {}

Which is called when the application stops

to read it back in look at the

public void onAppStart(IApplicationInstance appInstance) {}

Which is called when the application starts

To access properties of the application you can use

        appInstance.getProperties().setProperty("secureurlparams.publish", "12345.doPublishChange");

Shamrock

You can make the value of secureurlparams.publish can be a comma delimited list.

<Value>12349.doPublish,1245.doPublish</Value>

If you are using Wowza 2, it is usually better to use ModuleRTMPAuthenticate if you can with your encoder. Then you can have many username passwords in a file.

Richard

You can use HTTProvider, something like:

package com.wowza.wms.example.module.http;
import java.io.*;
import com.wowza.wms.http.*;
import com.wowza.wms.logging.*;
import com.wowza.wms.vhost.*;
public class HTTPUpdateApplicationPropertyExample extends HTTProvider2Base {
	public void onHTTPRequest(IVHost vhost, IHTTPRequest req, IHTTPResponse resp) {
		if (!doHTTPAuthentication(vhost, req, resp))
			return;
		
		vhost.getApplication("vod").getAppInstance("_definst_").getProperties().setProperty("secureurlparams.publish", "12349.doPublish");
		String OK = "Update OK";
		String retStr = "<html><head><title>" + OK
				+ "</title></head><body>" + OK + "</body></html>";
		try {
			OutputStream out = resp.getOutputStream();
			byte[] outBytes = retStr.getBytes();
			out.write(outBytes);
		} catch (Exception e) {
			WMSLoggerFactory.getLogger(null).error(
					"HTTPUpdateApplicationPropertyExample: " + e.toString());
		}
	}
}

Richard

You want to add yours 2nd to last, above the HTTPServerVersion. That one is a catchall, the RequestFilters is “*”, so anything below it will never get called. So make sure this one is last and yours are above it:

<HTTPProvider>
	<BaseClass>com.wowza.wms.http.HTTPServerVersion</BaseClass>
	<RequestFilters>*</RequestFilters>
	<AuthenticationMethod>none</AuthenticationMethod>
</HTTPProvider>

Richard

That is not possible as far as I know.

Shamrock

I created module with name updateSecureUrlParams. I added this module definitions in application.xml. I restarted server. When I try to connect from FME using

FMS URL: rtmp://localhost:1935/live/definst/doPublish=12346

Stream: live

I am unable to publish stream and it is not setting Property in application.xml. can you please identify my mistake. Below you can find my module code and application.xml

package com.wowza.wms.plugin.test.module;
import com.wowza.wms.application.*;
import com.wowza.wms.amf.*;
import com.wowza.wms.client.*;
import com.wowza.wms.module.*;
import com.wowza.wms.request.*;
import com.wowza.wms.stream.*;
import com.wowza.wms.rtp.model.*;
import com.wowza.wms.httpstreamer.model.*;
import com.wowza.wms.httpstreamer.cupertinostreaming.httpstreamer.*;
import com.wowza.wms.httpstreamer.smoothstreaming.httpstreamer.*;
public class updateSecureUrlParams extends ModuleBase {
	public void onAppStart(IApplicationInstance appInstance) {
		String fullname = appInstance.getApplication().getName() + "/"
				+ appInstance.getName();
		getLogger().info("onAppStart: " + fullname);
		appInstance.getProperties().setProperty("secureurlparams.publish",
				"12346.doPublish");
	}
}

updateSecureUrlParams

updateSecureURLParams

com.wowza.wms.plugin.test.module.updateSecureUrlParams

Hi

I am able to set the property but it is not working according to my need.

in application.xml I set properties likes this

<Properties>
			<Property>
				<Name>secureurlparams.publish</Name>
				<Value>12345.doPublish</Value>
			</Property>
			<Property>
				<Name>secureurlparams.publish</Name>
				<Value>12346.doPublish</Value>
			</Property>
		</Properties>

Suppose I want to update one more property and It should add this property under the above existing properties. When I try to connect using FME to doPublish=12345 it is unable to connect but I am able to connect when I use doPublish=12349.

Do you think set property is overwritten over existing properties?

How to overcome this issue. If there are 200 users I want to add this secure URL params for 200 in application.xml how can I achieve this goal. Manually I cannot edit and add for incoming users who want to stream on my website. Please give me Suggestion.

<Property>
				<Name>secureurlparams.publish</Name>
				<Value>12349.doPublish</Value>
			</Property>
appInstance.getProperties().setProperty("secureurlparams.publish", "12349.doPublish");
		

Thanks richard you solved my problem. I am using wowza 2. My plan is to retrieve all the secured params from database and add to application.xml. I don’t want to use username and passwords.

Is it possible to connect to the module from other server running tomcat. I don’t know flash I want to connect to this module to update application.xml from external web application. Is it possible if yes how can I solve.

Thanks

/batman

Thanks Richard for your reply. I compiled this in the Wowza IDE and added HTTProvider to last in the list of HTTProviders. I did not modified vhosts.xml. When I referenced I am getting Wowza Media Server 2 Developer 2.2.3 build26454. Can you identify my error. I tried vhostcount example which is available in this forum but result is same.

http://localhost:1935/HTTPUpdateApplicationPropertyExample

Here is my vhost.xml

<Root>
	<VHost>
		<HostPortList>
			<HostPort>
				<ProcessorCount>4</ProcessorCount>
				<IpAddress>*</IpAddress>
				<!-- Separate multiple ports with commas -->
				<!-- 80: HTTP, RTMPT -->
				<!-- 554: RTSP -->
				<Port>1935</Port>
				<SocketConfiguration>
					<ReuseAddress>true</ReuseAddress>
					<!-- suggested settings for video on demand applications -->
					<ReceiveBufferSize>24000</ReceiveBufferSize>
					<SendBufferSize>65000</SendBufferSize>
					<!-- suggest settings for low latency chat and video recording applications
					<ReceiveBufferSize>16000</ReceiveBufferSize>
					<SendBufferSize>16000</SendBufferSize>
					-->
					<KeepAlive>true</KeepAlive>
					<!-- <TrafficClass>0</TrafficClass> -->
					<!-- <OobInline>false</OobInline> -->
					<!-- <SoLingerTime>-1</SoLingerTime> -->
					<!-- <TcpNoDelay>false</TcpNoDelay> -->
					<AcceptorBackLog>100</AcceptorBackLog>
				</SocketConfiguration>
				<HTTPStreamerAdapterIDs>cupertinostreaming,smoothstreaming,sanjosestreaming</HTTPStreamerAdapterIDs>
				<HTTPProviders>
					<HTTPProvider>
						<BaseClass>com.wowza.wms.http.HTTPCrossdomain</BaseClass>
						<RequestFilters>*crossdomain.xml</RequestFilters>
						<AuthenticationMethod>none</AuthenticationMethod>
					</HTTPProvider>
					<HTTPProvider>
						<BaseClass>com.wowza.wms.http.HTTPClientAccessPolicy</BaseClass>
						<RequestFilters>*clientaccesspolicy.xml</RequestFilters>
						<AuthenticationMethod>none</AuthenticationMethod>
					</HTTPProvider>
					<HTTPProvider>
						<BaseClass>com.wowza.wms.http.HTTPServerVersion</BaseClass>
						<RequestFilters>*</RequestFilters>
						<AuthenticationMethod>none</AuthenticationMethod>
					</HTTPProvider>
                                       [COLOR="#ff8c00"] <HTTPProvider>
                                                <BaseClass>com.wowza.wms.example.module.http.HTTPUpdateApplicationPropertyExample</BaseClass>
                                                <RequestFilters>HTTPUpdateApplicationPropertyExample*</RequestFilters>
                                                <AuthenticationMethod>none</AuthenticationMethod>
                                        </HTTPProvider>
                                        <HTTPProvider>
                                            <BaseClass>com.wowza.wms.example.module.http.HTTPVHostCount</BaseClass>
                                            <RequestFilters>vhostcount*</RequestFilters>
                                            <AuthenticationMethod>none</AuthenticationMethod>
                                        </HTTPProvider>[/COLOR]
				</HTTPProviders>
			</HostPort>
			
			<!-- 443 with SSL -->
			<!--
			<HostPort>
				<ProcessorCount>4</ProcessorCount>
				<IpAddress>*</IpAddress>
				<Port>443</Port>
				<SSLConfig>
					<KeyStorePath>${com.wowza.wms.context.VHostConfigHome}/conf/keystore.cert</KeyStorePath>
					<KeyStorePassword>[password]</KeyStorePassword>
					<KeyStoreType>JKS</KeyStoreType>
					<SSLProtocol>TLS</SSLProtocol>
					<Algorithm>SunX509</Algorithm>
				</SSLConfig>
				<SocketConfiguration>
					<ReuseAddress>true</ReuseAddress>
					<ReceiveBufferSize>24000</ReceiveBufferSize>
					<SendBufferSize>65000</SendBufferSize>
					<KeepAlive>true</KeepAlive>
					<AcceptorBackLog>100</AcceptorBackLog>
				</SocketConfiguration>
				<HTTPStreamerAdapterIDs>cupertinostreaming,smoothstreaming,sanjosestreaming</HTTPStreamerAdapterIDs>
				<HTTPProviders>
					<HTTPProvider>
						<BaseClass>com.wowza.wms.http.HTTPClientAccessPolicy</BaseClass>
						<RequestFilters>*clientaccesspolicy.xml</RequestFilters>
						<AuthenticationMethod>none</AuthenticationMethod>
					</HTTPProvider>
					<HTTPProvider>
						<BaseClass>com.wowza.wms.http.HTTPCrossdomain</BaseClass>
						<RequestFilters>*crossdomain.xml</RequestFilters>
						<AuthenticationMethod>none</AuthenticationMethod>
					</HTTPProvider>
					<HTTPProvider>
						<BaseClass>com.wowza.wms.http.HTTPServerVersion</BaseClass>
						<RequestFilters>*</RequestFilters>
						<AuthenticationMethod>none</AuthenticationMethod>
					</HTTPProvider>
				</HTTPProviders>
			</HostPort>
			-->
			
			<!-- Admin HostPort -->
			<HostPort>
				<ProcessorCount>1</ProcessorCount>
				<IpAddress>*</IpAddress>
				<Port>8086</Port>
				<SocketConfiguration>
					<ReuseAddress>true</ReuseAddress>
					<ReceiveBufferSize>16000</ReceiveBufferSize>
					<SendBufferSize>16000</SendBufferSize>
					<KeepAlive>true</KeepAlive>
					<AcceptorBackLog>100</AcceptorBackLog>
				</SocketConfiguration>
				<HTTPStreamerAdapterIDs></HTTPStreamerAdapterIDs>
				<HTTPProviders>
					<HTTPProvider>
						<BaseClass>com.wowza.wms.http.streammanager.HTTPStreamManager</BaseClass>
						<RequestFilters>streammanager*</RequestFilters>
						<AuthenticationMethod>admin-digest</AuthenticationMethod>
					</HTTPProvider>
					<HTTPProvider>
						<BaseClass>com.wowza.wms.http.HTTPServerInfoXML</BaseClass>
						<RequestFilters>serverinfo*</RequestFilters>
						<AuthenticationMethod>admin-digest</AuthenticationMethod>
					</HTTPProvider>
					<HTTPProvider>
						<BaseClass>com.wowza.wms.http.HTTPConnectionInfo</BaseClass>
						<RequestFilters>connectioninfo*</RequestFilters>
						<AuthenticationMethod>admin-digest</AuthenticationMethod>
					</HTTPProvider>
					<HTTPProvider>
						<BaseClass>com.wowza.wms.http.HTTPConnectionCountsXML</BaseClass>
						<RequestFilters>connectioncounts*</RequestFilters>
						<AuthenticationMethod>admin-digest</AuthenticationMethod>
					</HTTPProvider>
					<HTTPProvider>
						<BaseClass>com.wowza.wms.http.HTTPServerVersion</BaseClass>
						<RequestFilters>*</RequestFilters>
						<AuthenticationMethod>none</AuthenticationMethod>
					</HTTPProvider>
                                      
				</HTTPProviders>
			</HostPort>
		
		</HostPortList>
		
		<HTTPStreamerAdapters>
			<HTTPStreamerAdapter>
				<ID>smoothstreaming</ID>
				<Name>smoothstreaming</Name>
				<Properties>
				</Properties>
			</HTTPStreamerAdapter>
			<HTTPStreamerAdapter>
				<ID>cupertinostreaming</ID>
				<Name>cupertinostreaming</Name>
				<Properties>
				</Properties>
			</HTTPStreamerAdapter>
			<HTTPStreamerAdapter>
				<ID>sanjosestreaming</ID>
				<Name>sanjosestreaming</Name>
				<Properties>
				</Properties>
			</HTTPStreamerAdapter>
		</HTTPStreamerAdapters>

		<HandlerThreadPool>
			<PoolSize>120</PoolSize>
		</HandlerThreadPool>
		<TransportThreadPool>
			<PoolSize>80</PoolSize>
		</TransportThreadPool>
		<IdleWorkers>
			<WorkerCount>4</WorkerCount>
			<CheckFrequency>50</CheckFrequency>
			<MinimumWaitTime>5</MinimumWaitTime>
		</IdleWorkers>
		<NetConnections>
			<ProcessorCount>4</ProcessorCount>
			<IdleFrequency>250</IdleFrequency>
			<SocketConfiguration>
				<ReuseAddress>true</ReuseAddress>
				<ReceiveBufferSize>65000</ReceiveBufferSize>
				<SendBufferSize>24000</SendBufferSize>
				<KeepAlive>true</KeepAlive>
				<!-- <TrafficClass>0</TrafficClass> -->
				<!-- <OobInline>false</OobInline> -->
				<!-- <SoLingerTime>-1</SoLingerTime> -->
				<!-- <TcpNoDelay>false</TcpNoDelay> -->
				<AcceptorBackLog>100</AcceptorBackLog>
			</SocketConfiguration>
		</NetConnections>
		<HTTPTunnel>
			<KeepAliveTimeout>2000</KeepAliveTimeout>
		</HTTPTunnel>
		<Client>
			<ClientTimeout>90000</ClientTimeout>
			<IdleFrequency>250</IdleFrequency>
		</Client>
		<!-- RTP/Authentication/Methods defined in Authentication.xml. Default setup includes; none, basic, digest -->
		<RTP>
			<IdleFrequency>75</IdleFrequency>
			<DatagramConfiguration>
				<Incoming>
					<ReuseAddress>true</ReuseAddress>
					<ReceiveBufferSize>256000</ReceiveBufferSize>
					<SendBufferSize>65000</SendBufferSize>
					<!-- <MulticastBindToAddress>true</MulticastBindToAddress> -->
					<!-- <MulticastInterfaceAddress>192.168.1.22</MulticastInterfaceAddress> -->
					<!-- <TrafficClass>0</TrafficClass> -->
					<MulticastTimeout>50</MulticastTimeout>
					<DatagramMaximumPacketSize>4096</DatagramMaximumPacketSize>
				</Incoming>
				<Outgoing>
					<ReuseAddress>true</ReuseAddress>
					<ReceiveBufferSize>65000</ReceiveBufferSize>
					<SendBufferSize>65000</SendBufferSize>
					<!-- <MulticastBindToAddress>true</MulticastBindToAddress> -->
					<!-- <MulticastInterfaceAddress>192.168.1.22</MulticastInterfaceAddress> -->
					<!-- <TrafficClass>0</TrafficClass> -->
					<MulticastTimeout>50</MulticastTimeout>
					<DatagramMaximumPacketSize>4096</DatagramMaximumPacketSize>
				</Outgoing>
			</DatagramConfiguration>
			<UnicastIncoming>
				<ProcessorCount>4</ProcessorCount>
			</UnicastIncoming>
			<UnicastOutgoing>
				<ProcessorCount>8</ProcessorCount>
			</UnicastOutgoing>
			<MulticastIncoming>
				<ProcessorCount>4</ProcessorCount>
			</MulticastIncoming>
			<MulticastOutgoing>
				<ProcessorCount>4</ProcessorCount>
			</MulticastOutgoing>
		</RTP>
		<Application>
			<ApplicationTimeout>60000</ApplicationTimeout>
			<PingTimeout>12000</PingTimeout>
			<ValidationFrequency>20000</ValidationFrequency>
			<MaximumPendingWriteBytes>0</MaximumPendingWriteBytes>
			<MaximumSetBufferTime>60000</MaximumSetBufferTime>
		</Application>
		<StartStartupStreams>true</StartStartupStreams>
		<!-- Properties defined here will be added to the IVHost.getProperties() collection -->
		<Properties>
		</Properties>
	</VHost>
</Root>

vhosts.xml

<Root>
	<VHosts>
		<VHost>
			<Name>_defaultVHost_</Name>
			<ConfigDir>${com.wowza.wms.ConfigHome}</ConfigDir>
			<ConnectionLimit>0</ConnectionLimit>
		</VHost>
	</VHosts>
</Root>

Thanks

/Batman

Hello Richard, my problem is solved. Thank you very much for your support.

when I call setProperty method why property is not seen in application.xml. I am able to stream using doPublish param in RTMP url but when I restart my server every thing is lost again I need to set property. How to add property permenately ie written to xml file.

vhost.getApplication("vod").getAppInstance("_definst_").getProperties().setProperty("secureurlparams.publish", "12349.doPublish");

Thanks