string url = "http://www.example.com/feed.xml";
var settings = new XmlReaderSettings();
settings.IgnoreComments = true;
settings.IgnoreProcessingInstructions = true;
settings.IgnoreWhitespace = true;
settings.XmlResolver = null;
settings.DtdProcessing = DtdProcessing.Parse;
settings.CheckCharacters = false;
var request = (HttpWebRequest)WebRequest.Create(url);
request.Timeout = 900000;
request.KeepAlive = true;
request.IfModifiedSince = lastModified;
var response = (HttpWebResponse)request.GetResponse();
Stream stream;
stream = response.GetResponseStream();
stream.ReadTimeout = 600000;
var xmlReader = XmlReader.Create(stream, settings);
while (!xmlReader.EOF)
{
...
When I try this on a large xml file (that is also very slow to download), my azure web app throws a blank page after a couple of minutes.
I saw this on Azure's Failed Request Tracing Logs:
ModuleName: DynamicCompressionModule
Notification: SEND_RESPONSE
HttpStatus: 500
HttpReason: Internal Server Error
HttpSubStatus: 19
ErrorCode: An operation was attempted on a nonexistent network connection. (0x800704cd)
As you can see, I have been "playing around" with the timeout settings. Also tried catching all exceptions but it doesn't catch any.
Also, this works without problems when debugging the web app locally on my computer. It could be that the internet connection at my office is better than Azure's, resulting on the xml file being read fast without any problems.
Any possible workarounds? Edit: I want to keep streaming the XML file (I'm avoiding downloading the whole file because the user has an option to read only the first N entries of the feed). In case the problem described above can't be avoided, I will be happy if someone can help me displaying a meaningful message to the user at least, instead of blank page.