title: "An existing connection was forcibly closed by the remote host" when connecting to same site in SSL
body: <p>Ok, for our site, which I will say is "<a href="https://www.foo-bar.com" rel="nofollow">https://www.foo-bar.com</a>", and is a .NET MVC 4.5.1 application, we have the following code:</p>
  
  <pre><code>var http = (HttpWebRequest)WebRequest.Create("https://www.foo-bar.com/category.rss");
  var response = http.GetResponse();
  
  var stream = response.GetResponseStream();
  var sr = new StreamReader(stream);
  s = sr.ReadToEnd();
  </code></pre>
  
  <p>This works locally, AND it works in production under "http", but as soon as we go to https, we get the following error:</p>
  
  <pre><code>{  
     "ClassName":"System.Net.WebException",
     "Message":"The underlying connection was closed: An unexpected error occurred on a send.",
     "Data":null,
     "InnerException":{  
        "ClassName":"System.IO.IOException",
        "Message":"Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.",
        "Data":null,
        "InnerException":{  
           "NativeErrorCode":10054,
           "ClassName":"System.Net.Sockets.SocketException",
           "Message":"An existing connection was forcibly closed by the remote host",
           "Data":null,
           "InnerException":null,
           "HelpURL":null,
           "StackTraceString":" at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)\r\n at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)",
           "RemoteStackTraceString":null,
           "RemoteStackIndex":0,
           "ExceptionMethod":"8\nReceive\nSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\nSystem.Net.Sockets.Socket\nInt32 Receive(Byte[], Int32, Int32, System.Net.Sockets.SocketFlags)",
           "HResult":-2147467259,
           "Source":"System",
           "WatsonBuckets":null
        },
        "HelpURL":null,
        "StackTraceString":" at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)\r\n at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)\r\n at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)\r\n at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)\r\n at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)\r\n at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)\r\n at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)\r\n at System.Net.TlsStream.CallProcessAuthentication(Object state)\r\n at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)\r\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)\r\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)\r\n at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)\r\n at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)\r\n at System.Net.ConnectStream.WriteHeaders(Boolean async)",
        "RemoteStackTraceString":null,
        "RemoteStackIndex":0,
        "ExceptionMethod":"8\nRead\nSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\nSystem.Net.Sockets.NetworkStream\nInt32 Read(Byte[], Int32, Int32)",
        "HResult":-2146232800,
        "Source":"System",
        "WatsonBuckets":null
     },
     "HelpURL":null,
     "StackTraceString":" at System.Net.HttpWebRequest.GetResponse()\r\n at ASP._Page_Views_home_Test_cshtml.Execute() in c:\\inetpub\\wwwroot\\foobarweb_dev\\Views\\Home\\Test.cshtml:line 14",
     "RemoteStackTraceString":null,
     "RemoteStackIndex":0,
     "ExceptionMethod":"8\nGetResponse\nSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\nSystem.Net.HttpWebRequest\nSystem.Net.WebResponse GetResponse()",
     "HResult":-2146233079,
     "Source":"System",
     "WatsonBuckets":null
  }
  </code></pre>
  
  <p>I've read suggestion to edit the following settings, and I have tinkered with them all, but no matter what combination I use, I still get the above error:</p>
  
  <pre><code>http.KeepAlive
  http.ProtocolVersion
  http.ServicePoint.ConnectionLimit
  http.Timeout
  </code></pre>
  
  <p>If I try this in another project on my local computer, connecting to the "https" version of the site works. It is <strong><em>only</em></strong> when connecting from within the site over SSL.</p>
  
  <p>I am stumped, and I'm not even sure if this is a code issue, a server issue, or maybe even a proxy/firewall issue.</p>