Results 1 to 3 of 3

Thread: Stream not found before onHTTPSessionCreate

  1. #1
    Join Date
    Jun 2012
    Posts
    19

    Default Stream not found before onHTTPSessionCreate

    Hello!

    I'm trying to use the onHTTPSessionCreate to redirect HTTP streaming sessions to a given EDGE server selected by the load balance redirector.

    The code I'm using for this redirection:

    public class HTTPRedirector extends ModuleBase
    {
    	private ILoadBalancerRedirector Redirector = null;
    	
    	private ILoadBalancerRedirector getRedirector()
    	{
    		if (this.Redirector == null)
    		{
    			while(true)
    			{
    				LoadBalancerListener listener = (LoadBalancerListener)Server.getInstance().getProperties().get(ServerListenerLoadBalancerListener.PROP_LOADBALANCERLISTENER);
    				if (listener == null)
    				{
    					Log.error("HTTPLoadBalancerRedirector.constructor: LoadBalancerListener not found.");
    				}
    				
    				this.Redirector = listener.getRedirector();
    				if (this.Redirector == null)
    				{
    					Log.error("HTTPLoadBalancerRedirector.constructor: ILoadBalancerRedirector not found.");
    					break;
    				}
    				break;
    			}
    		}
    		
    		return this.Redirector;
    	}
    
    	public void onAppStart(IApplicationInstance appInstance)
    	{
    		getRedirector();
    	}
    
    	public void onHTTPSessionCreate(IHTTPStreamerSession httpSession)
    	{
    		if (this.Redirector != null)
    		{
    			LoadBalancerRedirect redirect = this.Redirector.getRedirect();
    			
    			StringBuilder redirectURL = new StringBuilder();
    			redirectURL.append("http://");
    			redirectURL.append(redirect.getHost());
    			redirectURL.append(":");
    			redirectURL.append(httpSession.getServerPort());
    			redirectURL.append("/");
    			redirectURL.append(httpSession.getUri());
    			if (httpSession.getQueryStr() != null)
    			{
    				redirectURL.append("?");
    				redirectURL.append(httpSession.getQueryStr());
    			}
    			
    			httpSession.redirectSession(redirectURL.toString());
    		}
    	}
    }
    Putting the URL directly into browser location, everything works fine, the video even starts to play on ipad. But when I try to play using JWPlayer I'm getting a stream not found error from HTTPStreamerAdapterCupertinoStreamer.onCheckAvailability, what makes the onHTTPSessionCreate not to be called. They two request the same URL, but with some differences in HTTP header.

    Request from JWPLayer (does not work):

    GET /VCastingLive/1111/playlist.m3u8 HTTP/1.1
    Host: 54.232.217.21
    User-Agent: AppleCoreMedia/1.0.0.9B206 (iPad; U; CPU OS 5_1_1 like Mac OS X; pt_br)
    Accept: */*
    Range: bytes=0-1
    Accept-Encoding: identity
    X-Playback-Session-Id: A285F91A-542C-4C99-8132-9ED88D1F45D5
    Connection: keep-alive
    
    HTTP/1.1 404 Not Found
    Accept-Ranges: bytes
    Server: FlashCom/3.5.7
    Content-Length: 0
    From Safari (works):

    GET /VCastingLive/1111/playlist.m3u8 HTTP/1.1
    Host: 54.232.217.21
    User-Agent: Mozilla/5.0 (iPad; CPU OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: pt-br
    Accept-Encoding: gzip, deflate
    Connection: keep-alive
    
    HTTP/1.1 302 Found
    Date: Fri, 14 Jun 2013 20:50:29 GMT
    Location: http://54.232.215.200:80/VCastingLive/1111/playlist.m3u8
    Accept-Ranges: bytes
    Server: FlashCom/3.5.7
    Content-Length: 0
    Is there any way to avoid these Wowza checks for stream availability?

    Thanks!

    Renato A. Ferreira

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

    Default

    Renato,

    This article shows how to redirect HTTP request:
    http://www.wowza.com/forums/content....rver-side-code

    But involving Wowza at all like this when you have the Wowza Load Balancer in place does not make sense. You can grab least loaded server over http from any client, or do it in your application server as you are forming the player in a http response.

    Richard

  3. #3
    Join Date
    Jun 2012
    Posts
    19

    Default

    Richard,

    Even understanding everything I read about documentation and articles like the one you suggested, I considered that having one part of the server selecting decision in server-side (RTMP) and the other part (HTTP) in client-side will make things harder to keep and to be understood in future.

    The solution I chose was to create a simple asynchronous HTTP server map using grizzly, in the same way I was trying with onHTTPSessionCreate event, but being started as a ServerListener, what worked nicely with JWPlayer in Safari/IOS.

    Thank-you!

    Renato A. Ferreira

Similar Threads

  1. Replies: 5
    Last Post: 06-02-2014, 09:35 AM
  2. Check for SSL in OnConnect and onHTTPSessionCreate
    By karelboek in forum Wowza Streaming Server Java API
    Replies: 0
    Last Post: 04-04-2014, 07:55 AM
  3. In Android the onHTTPSessionCreate method is called 3 times
    By magnesiosl85 in forum General Forum
    Replies: 1
    Last Post: 11-07-2013, 02:44 PM
  4. onHTTPSessionCreate does not trigger
    By Roy0817 in forum General Forum
    Replies: 16
    Last Post: 05-03-2013, 06:29 AM

Posting Permissions

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