title: Timeout: The underlying connection was closed: The connection was closed unexpectedly
body: <p>I am having a timeout issue.  The service that I am connecting with works fine when it responds in a timely fashion.  When it takes around 10 seconds, it times out with the exception.  Besides Timeout and ReadWriteTimeout, what other timeout properties can I set so that it waits properly?  Is there something I need to set at the TCP/IP level?  Thanks for your help.</p>
  
  <p>System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly.
  at System.Net.HttpWebRequest.GetResponse()</p>
  
  <p>Here is my code.  I have tried variations of many things:</p>
  
  <pre><code>'The post works
  Dim _httpRequest As HttpWebRequest
  _httpRequest = WebRequest.Create("mywebservice")
  System.Net.ServicePointManager.Expect100Continue = False
  _httpRequest.Credentials = CredentialCache.DefaultCredentials
  _httpRequest.ProtocolVersion = HttpVersion.Version10
  'This is a 60 second wait
  _httpRequest.Timeout = 60000 
  'This is a 60 second wait
  _httpRequest.ReadWriteTimeout = 60000
  _httpRequest.KeepAlive = False
  _httpRequest.Method = "POST"
  
  'If the response takes takes 10 seconds
  'This is the message we get:  System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly.
  
  _httpRequest.Method = "GET"
  _httpRequest.ContentType = "text/xml"
  'The error is here
  Dim httpResponse As HttpWebResponse = _httpRequest.GetResponse
  </code></pre>