Hi, I created a scanner for the site. After about 3 hours of scanning, my application stopped at WebException. below is my code in C #. The client has a predefined WebClientobject that will be deleted each time the gameDoc is already processed. gameDoc is an object HtmlDocument(from HtmlAgilityPack)
while (retrygamedoc)
{
try
{
gameDoc.LoadHtml(client.DownloadString(url));
retrygamedoc = false;
}
catch
{
client.Dispose();
client = new WebClient();
retrygamedoc = true;
Thread.Sleep(500);
}
}
I tried using the code below (to keep a fresh web client) from this answer
while (retrygamedoc)
{
try
{
using (WebClient client2 = new WebClient())
{
gameDoc.LoadHtml(client2.DownloadString(url));
retrygamedoc = false;
}
}
catch
{
retrygamedoc = true;
Thread.Sleep(500);
}
}
but the result is still the same. Then I use StreamReader and the result remains unchanged! below is my code using StreamReader.
while (retrygamedoc)
{
try
{
HttpWebRequest webreq = (HttpWebRequest)WebRequest.Create(url);
string responsestring = string.Empty;
HttpWebResponse response = (HttpWebResponse)webreq.GetResponse();
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
responsestring = reader.ReadToEnd();
}
gameDoc.LoadHtml(client.DownloadString(url));
retrygamedoc = false;
}
catch
{
retrygamedoc = true;
Thread.Sleep(500);
}
}
? , , , 1000 . The request was aborted: The connection was closed unexpectedly., ConnectionClosed
PS. .
:
, . , , , . , .
:
, 1300 -, The request was aborted: The connection was closed unexpectedly., - .