Results 1 to 8 of 8

Thread: c# HTTP get method for livestreamrecord

  1. #1
    Join Date
    Jul 2014
    Posts
    15

    Default c# HTTP get method for livestreamrecord

    Hello I need some help with livestreamrecord recording via http url c# calls,

    I can start and stop a stream recording using:

    http://[username]:[password]@[wowza-ip-address]:8086/livestreamrecord?app=live&streamname=myStream&action=startRecording

    When inputting it directly in to a browser but when I try to do the same from c# on a webpage nothing happens.

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://[username]:[password]@[wowza-ip-address]:8086/livestreamrecord?app=live&streamname=myStream&action=startRecording);
            request.Method = "GET";
            request.Proxy = new WebProxy("[wowza-ip-address]", 8086);
            request.Credentials = new NetworkCredential("[username]", "[password]");        
            request.ContentType = "application/x-www-form-urlencoded";
            
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream stm = response.GetResponseStream();
    When I first tried to set it up I kept getting 401 unauthorized error which the code above no long throws, but now I'm stuck as no error is thrown and still no recording is started.

    Ben

  2. #2
    Join Date
    May 2013
    Posts
    680

    Default

    Hello Ben,

    When you run the query via your application, what does it return now (as you said you aren't getting 401 responses any longer)? Have you tried querying http://[wowza-ip-address]:1935 and, if so, what does it return (should return wowza version string)?

    Thanks,

    Matt

  3. #3
    Join Date
    Jul 2014
    Posts
    15

    Default

    Hi Matt,

    It returns:

    <html><head><title>Wowza Streaming Engine 4 Perpetual Edition 4.0.1 build10615</title></head><body>Wowza Streaming Engine 4 Perpetual Edition 4.0.1 build10615</body></html>
    In both cases.

    Ben

  4. #4
    Join Date
    May 2013
    Posts
    680

    Default

    This would suggest the application is faulty here if the direct url (in the browser) initiates the recording and this doesn't. The fact that it gives you back the Wowza version html page would also suggest it isn't even hitting the livestreamrecord http provider (as the com.wowza.wms.http.HTTPServerVersion module returns this value).

    As a test for your c# application, you could set the AuthenticationMethod to "none" in the livestreamrecord HTTP Provider and see if you are able to have any further luck (ensure you *only* do this on a test environment as it will remove security from the livestreamrecord provider).

  5. #5
    Join Date
    Jul 2014
    Posts
    15

    Default

    Made a couple of changes and made the request as simple as possible.

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://[username]:[password]@[wowza-ip-address]:8086/livestreamrecord?app=live&streamname=myStream&action=startRecording);
            request.Method = "GET";
            request.Credentials = new NetworkCredential("[username]", "[password]", "[domain]");
            
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream stm = response.GetResponseStream();
    This now does stop and start the recordings but at the same time throws the error: The remote server returned an error: (401) Unauthorized.

    So it's telling me that it's not unauthorized but still runs the command.

  6. #6
    Join Date
    May 2013
    Posts
    680

    Default

    In my tests, I think one way you could handle it for test purposes, is to set AllowAutoRedirect to false as there is a 302 redirect (or handle the redirect appropriately). Something like the following as an example:
    string url = @"http://localhost:8086/livestreamrecord?app=live&streamname=myStream&action=startRecording";
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
    request.Method = "GET";
    request.ContentType = "text/plain";
    request.AllowAutoRedirect = false;
    request.Credentials = new NetworkCredential("[username]", "[password]");
    HttpWebResponse result = (HttpWebResponse)request.GetResponse();
    Stream receiveStream = result.GetResponseStream ();
    //.... cleanup etc..

  7. #7
    Join Date
    Jul 2014
    Posts
    15

    Default

    Thank you, setting
    request.AllowAutoRedirect = false;
    worked perfectly.

  8. #8
    Join Date
    May 2013
    Posts
    680

    Default

    Ok great. Thanks for the update.

    Matt

Similar Threads

  1. LiveStreamRecord HTTP Success/Fail?
    By weingage in forum AddOn: Other AddOns
    Replies: 6
    Last Post: 09-03-2014, 12:02 AM
  2. HTTP LiveStreamRecord and fileTemplate
    By jdbell in forum General Forum
    Replies: 1
    Last Post: 02-12-2014, 07:27 AM
  3. LiveStreamRecord HTTP API 3.5
    By novazion in forum AddOn: Other AddOns
    Replies: 7
    Last Post: 12-07-2012, 02:02 PM
  4. monitor livestreamrecord state from http provider
    By INVINTUS in forum Server-side Modules and Code Samples Discussion
    Replies: 1
    Last Post: 11-28-2011, 06:17 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
  •