Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: LimitConnections on a Server level (Server.xml or Vhost.xml onConnect) instead of app

  1. #1

    Question LimitConnections on a Server level (Server.xml or Vhost.xml onConnect) instead of app

    Hi
    We have a LimitConnections module which works great. It is set as a module in the conf/application/Application.xml.

    Is it possible to move this module from an application level to a server level? Basically we want to limit streams just like the wowza dev license does. So it would be better if we were monitoring connections on a server level instead of at each application.

    We do have a serverNotify2 module that can get global server connection counts. But how can we tie in to the onConnect, onHTTPSessionCreate, onRTPSessionCreate in the server.xml LoadMonitoring module which is implementing iServerNotify2.

    Is it possible to do it in a module that is set in VHost.xml which is a http module? This module can accept http requests from our website. Can we block incoming connections to wowza from such a module when a request is received to do so?

    We do not want to depend on the setting in VHosts.xml for max connections

    Thank you
    Last edited by arpan_synapse; 01-15-2013 at 01:44 PM.

  2. #2
    Join Date
    Dec 2007
    Posts
    21,962

    Default

    One way, broad-brush, is use the ServerListener to track connection counts across applications and maintain that count in a server property with WMSProperties, like this:
    server.getProperties().setProperty("globalCount", globalCount);
    then check that count in your application module, which you will have running in all applications that you want to limit with this info. In ModuleLimitConnectionsToApplication make this change, find the first line and comment it out and add the second line, below:
    //long count = app.getConnectionCounter().getCurrent();
    Server.getInstance().getProperties().getPropertyLong("globalCount", 0);
    Richard

  3. #3

    Default

    Hi Richard,

    Thanks for the WMS properties idea.

    Is it possible to reject connections in a Server Listener module like something that extends IServerNotify2 ? A constant thread that runs and keeps a count of all connections to the server.
    We would like to do this without having any module in the application.

  4. #4
    Join Date
    Dec 2007
    Posts
    21,962

    Default

    package test;
    
    import com.wowza.wms.application.IApplication;
    import com.wowza.wms.application.IApplicationInstance;
    import com.wowza.wms.application.IApplicationInstanceNotify;
    import com.wowza.wms.application.IApplicationNotify;
    import com.wowza.wms.client.IClient;
    import com.wowza.wms.client.IClientNotify;
    import com.wowza.wms.httpstreamer.model.IHTTPSessionNotify;
    import com.wowza.wms.httpstreamer.model.IHTTPStreamerSession;
    import com.wowza.wms.logging.*;
    import com.wowza.wms.server.*;
    import com.wowza.wms.vhost.IVHost;
    import com.wowza.wms.vhost.VHost;
    import com.wowza.wms.vhost.VHostSingleton;
    
    public class ServerListenerAppListener implements IServerNotify2 {
    	
    	class ClientNotifier implements IClientNotify
    	{
    		public void onClientAccept(IClient client) {			
    		}
    
    		public void onClientConnect(IClient client) {		
    			WMSLoggerFactory.getLogger(null).info("ServerListenerAppListener Client Connect");
    			
    		}
    
    		public void onClientDisconnect(IClient client) {			
    		}
    
    		public void onClientReject(IClient client) {		
    		}
    		
    	}
    
    	
    	class AppInstanceListener implements IApplicationInstanceNotify
    	{
    		public void onApplicationInstanceCreate(
    				IApplicationInstance applicationInstance) {
    			applicationInstance.addClientListener(new ClientNotifier());
    			
    		}
    
    		public void onApplicationInstanceDestroy(
    				IApplicationInstance applicationInstance) {
    			
    		}
    		
    	}
    
    
    
    	class ApplicationNotifier implements IApplicationNotify
    	{
    
    		public void onApplicationCreate(IApplication application) {
    			application.addApplicationInstanceListener(new AppInstanceListener());
    			
    		}
    
    		public void onApplicationDestroy(IApplication application) {
    		}
    		
    	}
    
    	
    
    	public void onServerConfigLoaded(IServer server) {
    		WMSLoggerFactory.getLogger(null).info("onServerConfigLoaded");
    	}
    
    	public void onServerCreate(IServer server) {
    		WMSLoggerFactory.getLogger(null).info("onServerCreate");
    	}
    
    	public void onServerInit(IServer server) {
    		WMSLoggerFactory.getLogger(null).info("onServerInit");
    		IVHost vhost = VHostSingleton.getInstance(VHost.VHOST_DEFAULT);
    		vhost.addApplicationListener(new ApplicationNotifier());
    	}
    
    	public void onServerShutdownStart(IServer server) {
    		WMSLoggerFactory.getLogger(null).info("onServerShutdownStart");
    	}
    
    	public void onServerShutdownComplete(IServer server) {
    		WMSLoggerFactory.getLogger(null).info("onServerShutdownComplete");
    	}
    
    }
    Last edited by rrlanham; 02-20-2013 at 04:42 PM.

  5. #5

    Default

    Thanks a lot for that code !
    @Override
    public void onClientConnect(IClient client) {
    // TODO Auto-generated method stub

    }


    If we do client.rejectConnection() here, will this apply to only rtmp connections ? or will httpsessions and rtp sessions also be rejected properly ?

  6. #6
    Join Date
    Dec 2007
    Posts
    21,962

    Default

    Actually, that won't work because the application instances are not started yet. You would have to listen for application instances somehow to add the client listener. Look around the ServerSide API, I am sure there is a way. Anyway, something to use parts of later perhaps. Beyond that, you will have to test and work through it, I am not sure, have not made anything like that. Obviously you could do what you are trying to do but it will take some work.

    Here it is, instead of using Iterator to drill down, use this IApplicationNotify
    vhost.addApplicationListener(applicationListener);
    Richard

  7. #7

    Default

    ok thanks Richard

  8. #8
    Join Date
    Dec 2007
    Posts
    21,962

    Default

    I updated the example. I didn't test it, but that should be a good framework to do basic application connection handling without modules.

    Rihcard

  9. #9

    Default

    thank you.
    If we rejectConnection here
    public void onClientConnect(IClient client) {
    client.rejectConnection("");
    }

    will it reject all connnections including http and rtp or only rtmp ?

  10. #10
    Join Date
    Dec 2007
    Posts
    21,962

    Default

    No, IClient represents a Flash RTMP NetConnection. For HTTP and RTSP access control, take a look at these guides:

    http://www.wowza.com/forums/content....josestreaming)
    http://www.wowza.com/forums/content....TSP-RTP-stream

    You should be able to do all that in ServerListener as well. You will have to scout around the ServerSide API for similar notifiers.

    Richard

Page 1 of 2 12 LastLast

Similar Threads

  1. Wowza server only finding first vhost in VHosts.xml
    By nolageek in forum Server Administration Discussion
    Replies: 1
    Last Post: 05-28-2013, 03:28 PM
  2. Setting H264 level in xml?
    By Deckard in forum AddOn: Transcoder
    Replies: 3
    Last Post: 12-11-2011, 03:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •