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
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
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).
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..
Ok great. Thanks for the update.
Matt
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
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.
Thank you, setting
request.AllowAutoRedirect = false;
worked perfectly.
Hi Matt/Ben,
I’m getting exactly same issue, tried the suggest solution but it couldn’t resolved my issue.
Whatever we send in request, every time we getting same response
It reeturns:
<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>
After upgrading to wowza 4.8.5 version, we getting below issue
<title>Wowza Streaming Engine 4 Subscription Edition 4.8.5 build20200616153358</title>
Wowza Streaming Engine 4 Subscription Edition 4.8.5 build20200616153358
This is the response I usually get from hitting port 8086 or 1935 instead of 8087. Can you try the same query but on port 8087?
Also make sure you are using the right authentication strategy that matches your Server.xml config. I use digest, and do something like this -
var credCache = new CredentialCache();
credCache.Add(new Uri(url), "Digest", new NetworkCredential(user, password));
var httpClient = new HttpClient(new HttpClientHandler { Credentials = credCache });
var response = await httpClient.GetAsync(url);
1 Like
Thanks Amara_Graham for your valuable suggestion.
It’s an issue with Wowza new updates (Version 4.8.5), which has been sorted out.
Now we’re facing another issue i.e. when we try to start recording on other instance than defInst, it says “Stream Not Found: test.stream”. while it exists on stream files
Do you have an idea?
Hi Seamus,
I somehow missed this post. Are you still experiencing this issue? If so, I would recommend opening a support ticket.
Thanks Amara_Graham.
This issue had been resolved.