UPDATE
See the bottom for the solution.
I'm trying to download reports in my ASP.Net MVC app in a loop. The first two always succeed, and the third always fails. It doesn't matter what order I run them in, it's always the third one that fails (which means that it's not the specific report, but the sequence that matters). When the reports succeed, they always come back in under 10 seconds, so it's not really a timeout. Please see the below code and scenarios.
Code
public Stream SomeMethodThatDownloadReports(string link)
{
using (var webClient = new WebClient())
{
webClient.Credentials = configuration.GetNetworkCredentialsForDownload();
try
{
return new MemoryStream(webClient.DownloadData(link));
}
catch (Exception ex)
{
throw new ReportDownloadFailureException(string.Format("Problem accessing Report. Report Url = {0}", link), ex);
}
}
}
Scenarios
- Don't skip
- A - Succeeds in < 10 seconds
- B - Succeeds in < 10 seconds
- C - Times out
- Skip one
- A - Skip
- B - Succeeds in < 10 seconds
- C - Succeeds in < 10 seconds
- D - Times out
- Randomize
- B - Succeeds in < 10 seconds
- G - Succeeds in < 10 seconds
- H - Times out
UPDATE
As it turns out. The real reason for the timeouts was that NHibernate was trying to update objects even though it shouldn't have (long story) as a prerequisite to the call to the reports. For some reason, it managed to successfully flush the calls before the report was called for the first two calls, but by the third one, it always got behind and caused a deadlock in the database... hence the timeout.