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