Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Getting the hostname for the request in the Random Access Reader class

  1. #1

    Default Getting the hostname for the request in the Random Access Reader class


    We're using a customized version of the Random Access Reader class and would like to use the hostname of the incoming request to determine what HTTP server to proxy from. Is there a way to get this information in the init() method?

    public void init(IApplicationInstance appInstance, IMediaStream stream, String basePath, String mediaName, String mediaExtension) {}

  2. #2
    Join Date
    Sep 2011


    You can't do it like that you would need to use a prior method that is called first.

    Try this as a starting point,

    The code here may suit your needs better.


  3. #3


    We're already using a custom module that overrides play(), onHTTPCupertinoStreamingSessionCreate(), onHTTPSmoothStreamingSessionCreate() and onRTPSessionCreate() for RTMP, HLS, Silverlight and RTSP respectively. In the case of RTMP and RTSP, the play() and onRTPSessionCreate() methods are called first. The problem we're facing is with HLS. Wowza calls the init() method in the RandomAccessReader class first before it gets to onHTTPCupertinoStreamingSessionCreate(). And when we're dealing with SMIL files, every time there's a bitrate switch, it's the init() method that's called.

    Here is a snippet of our wowza logs for an HLS request. I added the MediaReaderListener to our custom module as well. As you can see, after the application starts, only the onMediaReaderCreate method is called after which it jumps to the init() method in our custom Random Access Reader class.

    2012-04-25 14:18:57 INFO application app-start _definst_ vod/_definst_
    2012-04-25 14:18:57 INFO server comment - MediaReaderListener onMediaReaderCreate
    2012-04-25 14:18:57 INFO server comment - CustomRandomAccessReader.init: basePath:/vol1/ mediaName:test.mp4 extension:mp4

  4. #4


    The only way would be through stream.getHTTPStreamerSession(). There is a chance that is populated at that point in time and you can get the domain through the HTTP session.


  5. #5


    Unfortunately, it's not. I am able to get stream.getContextStr() however but that only spits out the path starting with the application name. Was hoping there's an API for the domain as well.


  6. #6


    What we're trying to do is use the hostname to identify the customer so we can pick the appropriate origin server to proxy from. stream.getContextStr() gets us the application name but using that to identify the customer is not going to scale since it would mean creating a custom application for every customer.

  7. #7


    Are you only see this when the RandomAccessReader is used to open a SMIL file? I can see that we use a disconnected IMediaStream to open SMIL files. this stream is not populated with the HTTP session information.


  8. #8


    The init() method in the RandomAccessReader class is always called first for an HLS request regardless of whether it's a SMIL file or not. However, for a regular HLS stream, onHTTPCupertinoStreamingSessionCreate() is called at a later point. But for SMIL files, whenever there's a shift to a different bitrate, only the init method is called. And you're right, I'm unable to even get the sessionId for it.

  9. #9


    I don't think it is a good idea to rely on this behavior. We can't guarentee that it will continue to work that way. What exactly are you trying to accomplish. Maybe there is a better way to do it.


  10. #10


    We're tying to pick the appropriate customer origin to proxy content from and serve via our wowza servers. We'd like to identify the customer based on the hostname in the request.

    For example, customer foo makes the following HLS request to our wowza servers (where is a CNAME to our wowza server):
    We'd like to use the hostname '' to determine that this is the customer 'foo' and proxy Extremists.m4v from their origin.

Page 1 of 2 12 LastLast

Similar Threads

  1. PushPublish: hostname can't be null
    By bmckim in forum Server-side Modules and Code Samples Discussion
    Replies: 5
    Last Post: 05-03-2012, 10:51 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