title: C# Web Request Exception: The underlying connection was closed: An unexpected error occurred on a receive
body: <p>Normally, this code works completely fine, but I have a single instance on a customers PC which is throwing this exception. We can't replicate at all. As in the subject, the exception I am getting is "The underlying connection was closed: An unexpected error occurred on a receive." I have researched the hell out of this but all I could find was setting KeepAlive to false, which I have already done. This is normally an SSL connection, but I have had the customer attempt the same connection over standard http and we got the same results.</p>
  
  <p>It is a super fast web request usually, with the userinfo class having about 10 string elements, and the response in a string of about 100 characters after a tiny MySQL query. So I don't think this is a timeout thing.</p>
  
  <p>Any ideas?</p>
  
  <pre><code>public static string HitServer(string url)
          {
  
              if (UserInfo.Instance == null) return "";
              //Request update XML path
              HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
              req.KeepAlive = false;
              req.Method = "POST";
              req.ContentType = "xml/text";
              using (Stream reqStream = req.GetRequestStream())
              {
                  XmlSerializer s = new XmlSerializer(typeof(UserInfo));
                  s.Serialize(reqStream, UserInfo.Instance);
              }
  
              WebResponse response = req.GetResponse();
              Stream responseStream = response.GetResponseStream();
              StreamReader sr = new StreamReader(responseStream);
              return sr.ReadToEnd();
          }
  </code></pre>