WowzaStreamingEngine needs CORS header sent on playlist.m3u8

Hi I am trying to figure out a way to add a simple header Access-Control-Allow-Origin: “*” to the playlist.m3u8 and other playlist files or the whole server for that matter, whatever works as long as I can set the header. I am using WowzaStreamingEngine-4.0.3 and I simply need to add a cors header to the playlist file, the connections on port 1935, or any request to the wowza client. I found a few other threads that look like they would work, just not quite. I tried to add a new .jar file to the server /lib/ module and enable it in the back end of the server. Kind of like what this guy is doing here.

I created a file called headers.class which contains this code.

package com.vermontinternetdesign.module; 
 
import com.wowza.wms.module.*; 
import com.wowza.wms.client.*; 
import com.wowza.wms.amf.*; 
import com.wowza.wms.request.*; 
 
public class httpHeader extends ModuleBase 
{ 
 public void onAppStart(IApplicationInstance appInstance) 
 { 
     
 } 
 public void onHTTPSessionCreate(IHTTPStreamerSession httpSession){
	getLogger().info("ModuleHTTPTestPlayStart.onHTTPSessionCreate: "+httpSession.getSessionId());
	httpSession.setUserHTTPHeader("WowzaTestHeader", "Wowza Rocks");
 }
 public void doSomething(IClient client, RequestFunction function, 
 AMFDataList params) 
 { 
 
 } 
} 

then I created a .jar file using this command from inside the /lib/

jar cf httpHeader.jar headers.class

Than I went to the application in the admin section and added a module

named httpHeader and gave it a qualified class name of

com.vermontinternetdesign.module.httpHeader

This did not produce a header for me unfortunely.

We are working on a very important project with the WowzaStreamingEngine however, I have tried 50 different ways to sunday in order to get a simple header sent so that I can access the playlist through an ajax request. Seems like a pretty remedial feature which should have a simple way to turn a cors header on and off. As the WowzaStreamingEngine is about useless to us if we cannot find a solution to this. I am not a Java programmer, I am a php programmer. However, if someone can show me a step by step way of adding this header to Wowza then the software will be very useful to me and I promise to recommend wowza to my future clients. I really don’t want to have to switch to another Engine at this point in time. As adding a header to a request is usually a very simple procedure. Thank you for reading this and I hope someone can point me in the right direction. I have already looked the internet up and down and looked at the other threads. None of which helped me solve the problem. They pointed me in the right direction. However, I still don’t have a header and this is holding up an entire project and client is getting ancy because I recommended this software. Not thinking it was going to take an act of God to display a cors header.The crossdoman.xml and accesspolicy.xml are all set up to allow these connections. All I need to know is how to send a header any header and that is it. I don’t program in Java but, I do program in other languages so I need a step by step thank you very much and if you can provide a solution for me. I might love you so much that I will give you some paid work to do. As I have several other people who want similar systems set up, and if we can get past this issue. It will generate a lot of work to do.

Thank you In advance,

John Anderson

http://www.vermontinternetdesign.com http://www.vtwe.com

Hi John,

The setUserHTTPHeader method is the correct one to use for this purpose.

To debug, check the log files and see if your module method is being called when you make the connection.

You should see the ModuleHTTPTestPlayStart.onHTTPSessionCreate: message logged along with the session id.

Also look for logging errors that may point to the problem. Look for errors related to not being able to load the class or xml errors.

Please post the relevant parts of your log files and Application.xml which would assist in diagnosing the issue.

Roger.

Hi,

As long as you are using Wowza 3.5 or above then you can add a property in your Application.xml by under HTTPStreams/Properties container.

cupertinoUserHTTPHeaders

Access-Control-Allow-Origin: *

If you want multiple headers do

cupertinoUserHTTPHeaders

Access-Control-Allow-Origin: *|AnotherHeaderToReturn: Me

No need for any code.

Andrew.

I don’t see any relevant errors in the wowzastreamingengine_error.log or _access.log in the Application.xml I can see this section has a reference to the class. Is there another log that I should be looking in? Or a better way to tell if the module is being lodaded.

 <Modules>
                        <Module>
                                <Name>base</Name>
                                <Description>Base</Description>
                                <Class>com.wowza.wms.module.ModuleCore</Class>
                        </Module>
                        <Module>
                                <Name>logging</Name>
                                <Description>Client Logging</Description>
                                <Class>com.wowza.wms.module.ModuleClientLogging</Class>
                        </Module>
                        <Module>
                                <Name>httpHeader</Name>
                                <Description>CORS HEADER</Description>
                                <Class>com.vermontinternetdesign.module.httpHeader</Class>
                        </Module>
                        <Module>
                                <Name>flvplayback</Name>
                                <Description>FLVPlayback</Description>
                                <Class>com.wowza.wms.module.ModuleFLVPlayback</Class>
                        </Module>
                        <Module>
                                <Name>ModuleCoreSecurity</Name>
                                <Description>Core Security Module for Applications</Description>
                                <Class>com.wowza.wms.security.ModuleCoreSecurity</Class>
                        </Module>
                </Modules>

Hi John,

The setUserHTTPHeader method is the correct one to use for this purpose.

To debug, check the log files and see if your module method is being called when you make the connection.

You should see the ModuleHTTPTestPlayStart.onHTTPSessionCreate: message logged along with the session id.

Also look for logging errors that may point to the problem. Look for errors related to not being able to load the class or xml errors.

Please post the relevant parts of your log files and Application.xml which would assist in diagnosing the issue.

Roger.

That worked great! Thanx. I bet adding that into the documentation will save the next person like me a lot of time.

Hi,

As long as you are using Wowza 3.5 or above then you can add a property in your Application.xml by under HTTPStreams/Properties container.

cupertinoUserHTTPHeaders

Access-Control-Allow-Origin: *

If you want multiple headers do

cupertinoUserHTTPHeaders

Access-Control-Allow-Origin: *|AnotherHeaderToReturn: Me

No need for any code.

Andrew.

This appears to work. However one problem that I am having is that one of the TS segments is coming through without the header. The other3 are coming through with the header just fine. Just one of the segments is not. Any ideas?