Hi Arpan,
I can replicate the problem, and am seeing what can be done to fix it. I don’t think there is a configurable way to add the Access-Control-Allow-Origin header, but there is a work-around. I will check further for configurable option and make a request if necessary to add that. Meanwhile, the work-around is a simple HTTPProvider (You have to import wms-plugin-loadbalancer.jar from the Load Balancer package):
package com.wowza.wms.example.module;
import com.wowza.wms.http.*;
import com.wowza.wms.vhost.*;
import com.wowza.wms.plugin.loadbalancer.HTTPLoadBalancerRedirector;
public class HTTPLeastLoaded extends HTTPLoadBalancerRedirector {
public void onHTTPRequest(IVHost vhost, IHTTPRequest req, IHTTPResponse resp) {
if (!doHTTPAuthentication(vhost, req, resp))
return;
resp.setHeader("Access-Control-Allow-Origin", "*");
super.onHTTPRequest(vhost, req, resp);
}
}
Add the project .jar file to your Wowza /lib folder, then change the BaseClass of the HTTPProvider of the Load Balancer Listener
<HTTPProvider>
<BaseClass>com.wowza.wms.example.module.HTTPLeastLoaded</BaseClass>
<RequestFilters>*loadbalancer</RequestFilters>
<AuthenticationMethod>none</AuthenticationMethod>
<Properties>
<Property>
<Name>enableServerInfoXML</Name>
<Value>true</Value>
<Type>Boolean</Type>
</Property>
</Properties>
</HTTPProvider>
Then re-start Wowza.
I tested with this (from here):
<html>
<head><title>LB test</title></head>
<body>
<span id='leastloaded'>least loaded server</span>
<script>
function sendRequest(url,callback,postData) {
var req = createXMLHTTPObject();
if (!req) return;
var method = (postData) ? 'POST' : 'GET';
req.open(method,url,true);
req.setRequestHeader('User-Agent','XMLHTTP/1.0');
if (postData)
req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
req.onreadystatechange = function () {
if (req.readyState != 4) return;
if (req.status != 200 && req.status != 304) {
alert('HTTP error ' + req.status);
return;
}
callback(req);
}
if (req.readyState == 4) return;
req.send(postData);
}
var XMLHttpFactories = [
function () {return new XMLHttpRequest()},
function () {return new ActiveXObject('Msxml2.XMLHTTP')},
function () {return new ActiveXObject('Msxml3.XMLHTTP')},
function () {return new ActiveXObject('Microsoft.XMLHTTP')}
];
function createXMLHTTPObject() {
var xmlhttp = false;
for (var i=0;i<XMLHttpFactories.length;i++) {
try {
xmlhttp = XMLHttpFactories[i]();
}
catch (e) {
continue;
}
break;
}
return xmlhttp;
}
function handleRequest(req) {
document.getElementById('leastloaded').innerHTML = req.responseText;
}
sendRequest('http://[wowza-address]:1935/loadbalancer',handleRequest);
</script>
</body>
</html>
Richard