My application makes a lot of web requests, but I keep seeing a SocketException ErrorCode = 10053 after I make my first web request. It’s like every other request is failing. It feels like I’m not properly disposing of something. Any ideas?
This is the function I’m using to make a web request:
public static string DownloadContent(string url)
{
string content = null;
var request = WebRequest.Create(url) as HttpWebRequest;
if (request != null)
using (var response = request.GetResponse() as HttpWebResponse)
using (var responseStream = response.GetResponseStream())
{
var buffer = new byte[responseStream.Length];
responseStream.Read(buffer, 0, int.Parse(responseStream.Length.ToString()));
content = new String(Encoding.UTF8.GetChars(buffer));
}
request.Dispose();
return content;
}
Log files / exception: