title: The underlying connection was closed: An unexpected error occurred on a receive
body: <p>When I call the restful service with the following code, I am getting the error</p>
  
  <blockquote>
    <p>The underlying connection was closed: An unexpected error occurred on
    a receive.</p>
  </blockquote>
  
  <p>Code:</p>
  
  <pre><code>    Const url As String = "http://localhost:8003/Tracker/Tracker.svc/GetTrackerDetails"
  
          ServicePointManager.MaxServicePointIdleTime = 500
          ServicePointManager.UseNagleAlgorithm = True
          ServicePointManager.Expect100Continue = True
          ServicePointManager.CheckCertificateRevocationList = True
          ServicePointManager.DefaultConnectionLimit = ServicePointManager.DefaultPersistentConnectionLimit
  
          req = DirectCast(WebRequest.Create(url), HttpWebRequest)
          req.Method = "POST"
          req.ContentType = "application/xml; charset=utf-8"
          req.Timeout = 300000
          req.KeepAlive = False
          req.Headers.Add("SOAPAction", url)
  
  
          Dim xmlDoc = New XmlDocument With {.XmlResolver = Nothing}
  
          xmlDoc.Load(Server.MapPath("Request.xml"))
          Dim sXml As String = xmlDoc.InnerXml
          req.ContentLength = sXml.Length
          Dim sw = New StreamWriter(req.GetRequestStream())
          sw.Write(sXml)
          sw.Close()
  
          res = DirectCast(req.GetResponse(), HttpWebResponse)
          Dim responseStream As Stream = res.GetResponseStream()
          Dim streamReader = New StreamReader(responseStream)
  
          'Read the response into an xml document
          Dim soapResonseXmlDocument = New XmlDocument()
          soapResonseXmlDocument.LoadXml(streamReader.ReadToEnd())
  
  
          TextBox1.Text = Server.HtmlDecode(soapResonseXmlDocument.InnerXml)
          soapResonseXmlDocument.LoadXml(TextBox1.Text)
  </code></pre>
  
  <p>I am facing this error for the past few days. What is wrong with my calling code. Please help me out.</p>