Getting a webrequest timeout when trying to download large video files through WebDAM's (a third party content management system) API. Here is the basic code that is used to get the video.
public void StreamAsset(String AssetID, HttpResponse Response)
{
WebRequest request = request = WebRequest.Create(_api_url_v2 + "assets/" + AssetID + "/download");
request.Timeout = 200000;
// add OAuth header
request.Headers.Add("Authorization", "Bearer " + _access_token);
// get response from WebDAM web service
WebResponse response = request.GetResponse();
using (Stream file = response.GetResponseStream())
{
Int32 bytesRead = 0;
Byte[] buffer = new Byte[524000];
while ((bytesRead = file.Read(buffer, 0, buffer.Length)) > 0)
{
if (Response.IsClientConnected)
Response.OutputStream.Write(buffer, 0, bytesRead);
else
break;
}
file.Close();
}
}
}
Is there a more efficient way to write this code or do I just have to jack up the timeout property.
I get the pretty standard following error.
Stack Trace: [HttpException (0x80004005): Request timed out.]