Results 1 to 4 of 4

Thread: Redirect stream request to another Wowza server

  1. #1
    Join Date
    Jan 2016
    Posts
    2

    Default Redirect stream request to another Wowza server

    Hi,

    We have several Wowza servers in different networks with only one server being able to access the Internet. All clients first connect to the Internet connected server, and a module in this server collects the client information using either IClient.getIp(), HTTPStreamerSessionCupertino.getIpAddress(), HTTPStreamerSessionSmoothStreamer.getIpAddress(), or RTPSession.getIp(), and then redirects the request to the appropriate server depending on the client's address.

    In onAppStart we create a table with networks and their corresponding Wowza server information.

    Then, as you can see below, in onConnect and in onHTTPCupertinoStreamingSessionCreate (and in onHTTPSmoothStreamingSessionCreate and onRTPSessionCreate) the redirect takes place:

    public void onConnect(IClient client, RequestFunction function, AMFDataList params) {
    		for(int i = 0; i < redirect_table.size(); i++)
    		{
    			try
    			{
    				if(sameNetwork(redirect_table.get(i).network, client.getIp(), redirect_table.get(i).mask))
    				{
    					getLogger().info("In same network: " + redirect_table.get(i).network);
    					URI query = new URI(client.getUri());
    					String redirect = "rtmp://" + redirect_table.get(i).server + ":1935" + query.getPath(); 
    					getLogger().info("REDIRECT: " + redirect);
    					client.redirectConnection(redirect);
    				}
    			}
    			catch(Exception e)
    			{
    			
    			}
    		}
    		
    	}
    Log:
    2016-01-15 15:44:00 CST comment server INFO 200 - REDIRECT: rtmp://10.165.90.16:1935/mob-live _defaultVHost_ mob-live _definst_ 22.934
    public void onHTTPCupertinoStreamingSessionCreate(HTTPStreamerSessionCupertino httpSession) {
    		for(int i = 0; i < redirect_table.size(); i++)
    		{
    			try
    			{
    				if(sameNetwork(redirect_table.get(i).network, httpSession.getIpAddress(), redirect_table.get(i).mask))
    				{
    					getLogger().info("In same network: " + redirect_table.get(i).network);
    					URI query = new URI(httpSession.getUri());
    					String redirect = "http://" + redirect_table.get(i).server + ":1935/" + query.getPath();
    					getLogger().info("REDIRECT: " + redirect);
    					httpSession.redirectSession(redirect);
    				}
    			}
    			catch(Exception e)
    			{
    			
    			}
    		}
    	}
    A limitation of our module is that the redirect assumes the application name of the final destination server is the same as the Internet connected server. We'd like, for example, to redirect the client from rtmp://10.165.254.17:1935/mob-live/mob-cam-c001.stream to rtmp://10.165.90.16:1935/mob-internal/mob-cam-c001.stream. We naively tried to just replace the line
    String redirect = "rtmp://" + redirect_table.get(i).server + ":1935" + query.getPath();
    with
    String redirect = "rtmp://" + redirect_table.get(i).server + ":1935/mob-internal/mob-cam-c001.stream";
    to test one stream but it doesn't work since the stream path apparently is a more complex data structure.
    Does anyone have a suggestion on how can we do this?
    Thanks!

  2. #2
    Join Date
    May 2013
    Posts
    680

    Default

    Please follow up in with our ticket response #155126.

    Thanks,
    Matt

  3. #3
    Join Date
    Jan 2016
    Posts
    2

    Default

    Thanks, Matt.
    This simple solution you suggested worked great since we didn't have to re-generate the whole URI query variable, just replace a substring in the returned string from query.getPath()

    String newQueryPath = query.getPath().replace("mob-live","mob-internal");
    String redirect = "rtmp://" + redirect_table.get(i).server + ":1935"+newQueryPath;

  4. #4

    Default

    Thanks for the follow up and for posting the solution.

    Regards,

    Salvadore

Similar Threads

  1. redirect stream to another stream
    By a5lan98 in forum Live Streaming and Encoder Discussion
    Replies: 5
    Last Post: 12-04-2013, 03:08 PM
  2. Wowza 2 to redirect RTMP requests to another server
    By ooBaeD0mi8ie in forum Server Administration Discussion
    Replies: 2
    Last Post: 01-15-2013, 12:52 AM
  3. Simplest way to redirect RTMP connection to another server?
    By daveuofu in forum Server-side Modules and Code Samples Discussion
    Replies: 2
    Last Post: 03-19-2012, 05:10 PM
  4. Redirect streaming to another server
    By Javier in forum Performance Tuning Discussion
    Replies: 1
    Last Post: 02-29-2012, 12:24 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
  •