<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Engels Rajangam</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/engelsr/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/engelsr/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 03:48:40 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Moving to MS IDC, India</title>
      <link>https://docs.microsoft.com/archive/blogs/engelsr/moving-to-ms-idc-india</link>
      <pubDate>Tue, 27 May 2008 19:54:00 GMT</pubDate>
      <dc:creator><![CDATA[engelsr]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/engelsr/2008/05/27/moving-to-ms-idc-india/</guid>
      <description><![CDATA[Recently I decided to move to India for personal reasons. So I joined Microsoft India Development...]]></description>
      <content:encoded><![CDATA[<P>Recently I decided to move to India for personal reasons. So I joined Microsoft India Development Center at Hyderabad as a Program Manager. </P>
<P>I am still traveling&nbsp;to undergo&nbsp;trainings for my new role, but will eventually settle down in Hyderabad (July 2008?).</P>]]></content:encoded>
    </item>
    <item>
      <title>System.Net: Intial auto proxy delay resulting in requests failing with "the operation has timed out" exception</title>
      <link>https://docs.microsoft.com/archive/blogs/engelsr/system-net-intial-auto-proxy-delay-resulting-in-requests-failing-with-the-operation-has-timed-out-exception</link>
      <pubDate>Wed, 13 Feb 2008 09:43:00 GMT</pubDate>
      <dc:creator><![CDATA[engelsr]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/engelsr/2008/02/13/system-net-intial-auto-proxy-delay-resulting-in-requests-failing-with-the-operation-has-timed-out-exception/</guid>
      <description><![CDATA[Recently I came across an interesting issue. 
A windows service application (originally developed...]]></description>
      <content:encoded><![CDATA[<P>Recently I came across an interesting issue. </P>
<P>A windows service application (originally developed with VS2003/.NET Framework 1.1) is designed to make several HTTP(s) requests in multiple threads simultaneously. With upgrading to VS2008 and recompiling the code, the app started seeing several requests failing with "The operation has timed out" exceptions. </P>
<P>Taking a System.Net trace (<A href="https://msdn2.microsoft.com/en-us/library/ty48b824(VS.80).aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ty48b824(VS.80).aspx">https://msdn2.microsoft.com/en-us/library/ty48b824(VS.80).aspx</A>) showed several threads failing as follows.</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">System.Net Verbose: 0 : [6044] WebRequest::Create(<FONT color=#0000ff><A href="https://www.someserver.com/" mce_href="https://www.someserver.com/">https://www.someserver.com/</A></FONT>)</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; ProcessId=9616</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; DateTime=2008-02-08T21:45:52.3396033Z</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">System.Net Verbose: 0 : [6044] HttpWebRequest#38203409::HttpWebRequest(<A href="https://www.someserver.com/" mce_href="https://www.someserver.com/">https://www.someserver.com/</A>)</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; ProcessId=9616</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; DateTime=2008-02-08T21:45:52.3396033Z</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">System.Net Verbose: 0 : [6044] Exiting HttpWebRequest#38203409::HttpWebRequest() </SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; ProcessId=9616</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; DateTime=2008-02-08T21:45:52.3396033Z</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">System.Net Verbose: 0 : [6044] Exiting WebRequest::Create() &nbsp; -&gt; HttpWebRequest#38203409</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; ProcessId=9616</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; DateTime=2008-02-08T21:45:52.3396033Z</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">System.Net Verbose: 0 : [6044] HttpWebRequest#38203409::GetResponse()</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; ProcessId=9616</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; DateTime=<B><SPAN style="COLOR: red">2008-02-08T21:45:52.4021029Z</SPAN></B></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">System.Net Information: 0 : [6044] Associating HttpWebRequest#38203409 with ServicePoint#58391824</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; ProcessId=9616</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; DateTime=<B><SPAN style="COLOR: red">2008-02-08T21:46:12.4957243Z</SPAN></B></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">System.Net Error: 0 : [6044] Exception in the HttpWebRequest#38203409::EndGetResponse - The operation has timed out</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; ProcessId=9616</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; DateTime=2008-02-08T21:46:12.4957243Z</SPAN></P>
<P>From the above we can see that the request failed almost immediately with the exception. Taking a network trace I confirmed that the specific request above was not sent over the wire. </P>
<P>Checking the trace at the beginning I could see that the application started making numerous requests. However before these requests were sent on wire, .NET Framework was trying to detect auto proxy for the urls submitted. This took about 5-7 seconds, by which time there were numerous requests in queue. The timeout set for each request was 20 seconds, however most of them started failing as shown above. </P>
<P>Since auto proxy detection was added only from 2.0 and above, the application did not see the same problem with 1.1 .NET Framework.</P>
<P>In this case, the following were the possible solutions.</P>
<P>1. Disabling auto proxy and configure static proxy in the app.config for the application.<BR>2. Change code to wait for the&nbsp; the first request to complete (including auto proxy). Then start sending the requests from the application. </P>
<P>In our case, the issue was resolved by disabling auto proxy and setting static proxy in app.config. More information on doing this is available at <A href="https://msdn2.microsoft.com/en-us/library/sa91de1e(VS.80).aspx" mce_href="https://msdn2.microsoft.com/en-us/library/sa91de1e(VS.80).aspx">https://msdn2.microsoft.com/en-us/library/sa91de1e(VS.80).aspx</A></P>
<P mce_keep="true">&nbsp;</P>]]></content:encoded>
    </item>
    <item>
      <title>Response accumulating Web Filter running into performance issues...</title>
      <link>https://docs.microsoft.com/archive/blogs/engelsr/response-accumulating-web-filter-running-into-performance-issues</link>
      <pubDate>Mon, 21 Aug 2006 13:03:00 GMT</pubDate>
      <dc:creator><![CDATA[engelsr]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/engelsr/2006/08/21/response-accumulating-web-filter-running-into-performance-issues/</guid>
      <description><![CDATA[I have come across this specific issue couple of times now. 
A response accumulating web filter...]]></description>
      <content:encoded><![CDATA[<P>I have come across this specific issue couple of times now. </P>
<P>A response accumulating web filter (such as WebResponseModifier with the ISA 2004 SDK), does the following.</P>
<P>1. Accumulates resoponse to client in SF_NOTIFY_SEND_RAW_DATA notification.<BR>2. In SF_NOTIFY_END_OF_REQUEST notification, the filter writes modified or unmodified response to client using WriteClient. <BR>3. WriteClient takes a long time to complete. This is often seen when WriteClient is used to write HTTP status line and headers. </P>
<P>Note: MSDN docs on WriteClient confirm that web filters may run into performance issues with WriteClient. Please refer the following for more information.</P>
<P>WriteClient: <A href="https://msdn.microsoft.com/library/default.asp?url=/library/en-us/isasdk/isa/writeclient.asp">https://msdn.microsoft.com/library/default.asp?url=/library/en-us/isasdk/isa/writeclient.asp</A><BR>Best Practices: <A href="https://msdn.microsoft.com/library/en-us/isasdk/isa/best_practices_for_web_filters.asp?frame=true">https://msdn.microsoft.com/library/en-us/isasdk/isa/best_practices_for_web_filters.asp?frame=true</A></P>
<P>In IIS ISAPI, it is recommended NOT to use WriteClient for writing status line and headers but to use ServerSupportFunction.&nbsp; This is because IIS does not detect that the response to client includes headers (which may result in IIS not correcting / erroring out if the response HTTP message is not formatted correct), if WriteClient was used. <BR><BR>In a similar way, the above ISA WriteClient performance issue can be resolved by using ServerSupportFunction instead. This of course adds additional couple of lines of code to your solution, however this is a cleaner and optimal way of writing response to client. </P>
<P>More info on ServerSupportFunction in ISA SDK is available at <BR><A href="https://msdn.microsoft.com/library/en-us/isasdk/isa/serversupportfunction.asp?frame=true">https://msdn.microsoft.com/library/en-us/isasdk/isa/serversupportfunction.asp?frame=true</A></P>
<P>Example code snippet:</P>
<P>char szHeaders [1024] = "Cache-Control: no-cache, no-store\r\nContent-Type: text/html; charset=utf-8\r\nContent-Length: 228\r\nServer: Microsoft-IIS/6.0\r\n\r\n";</P>
<P>pfc-&gt;ServerSupportFunction(pfc, SF_REQ_SEND_RESPONSE_HEADER, (PVOID) "200 OK",&nbsp; (ULONG_PTR) szHeaders, NULL);</P>
<P>As you can see szHeaders&nbsp;is for adding any additional headers to&nbsp;the response. </P>
<P>Note: Do not add \r\n at the end of 200 OK (status). <BR></P>]]></content:encoded>
    </item>
    <item>
      <title>The underlying connection was closed...</title>
      <link>https://docs.microsoft.com/archive/blogs/engelsr/the-underlying-connection-was-closed</link>
      <pubDate>Tue, 29 Nov 2005 11:31:00 GMT</pubDate>
      <dc:creator><![CDATA[engelsr]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/engelsr/2005/11/29/the-underlying-connection-was-closed/</guid>
      <description><![CDATA[Please use the following KB article if you get any "Underlying connection was closed" error....]]></description>
      <content:encoded><![CDATA[<P><STRONG><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">Please use the following KB article if you get any "Underlying connection was closed" error. </SPAN></STRONG><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P><STRONG><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">915599&nbsp;You receive one or more error messages when you try to make an HTTP request in an application that is built on the .NET Framework 1.1 Service Pack 1</SPAN></STRONG><B><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><BR><STRONG><SPAN style="FONT-FAMILY: Arial"><A href="https://support.microsoft.com/default.aspx?scid=kb;EN-US;915599" mce_href="https://support.microsoft.com/default.aspx?scid=kb;EN-US;915599"><SPAN style="COLOR: #ffff99">https://support.microsoft.com/default.aspx?scid=kb;EN-US;915599</SPAN></A></SPAN></STRONG></SPAN><STRONG><SPAN style="COLOR: #ffff99"><o:p></o:p></SPAN></STRONG></B></P>
<P><B><SPAN style="FONT-SIZE: 10pt; COLOR: #ff6600; FONT-FAMILY: Arial">*********&nbsp;Content below will not be updated for any new/additional info,&nbsp;but the&nbsp;KB article&nbsp;will be&nbsp;****** So please use the KB article **********</SPAN></B><B><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><BR><BR>This posting is provided "AS IS" with no warranties, and confers no rights. You assume all risk for your use. © 2003 Microsoft Corporation. All rights reserved.</SPAN></B><SPAN style="COLOR: #ffff99"><o:p></o:p></SPAN></P>
<P><STRONG><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">Note:</SPAN></STRONG><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"> This discussion applies to .Net framework 1.1 and .Net framework 1.1 SP1 only. <o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">The above exception is usually reported by System.Net.HttpWebRequest class (which may bubble up to System.Net.WebClient or System.Web.Services.Protocols.SoapHttpClientProtocol).<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">Working with Microsoft customers, I know how they hate the above message. But this error is actually very helpful in determining what went wrong with the underlying connection, during HTTP request/response communication sequence between client and server processes. <o:p></o:p></SPAN></P>
<P><STRONG><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">Types of 'Underlying connection closed' Errors:</SPAN></STRONG><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">We typically see one of the following. The second part of the error indicates what may be the cause. <o:p></o:p></SPAN></P>
<P><EM><B><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">"The underlying connection was closed: Unable to connect to the remote server."</SPAN></B></EM><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><BR>--Seen when the webserver to which the HTTP request was sent, was unreachable. Usually caused by incorrect proxy configuration and/or by dns issues. <o:p></o:p></SPAN></P>
<P><EM><B><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">"The underlying connection was closed: An unexpected error occurred on a receive."</SPAN></B></EM><B><I><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><BR></SPAN></I></B><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">--Seen when the client had sent the request in its entirety and got a TCP ACK-FIN or RST from server to close the connection, without a response from server. <o:p></o:p></SPAN></P>
<P><EM><B><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">"The underlying connection was closed: An unexpected error occurred on a Send."</SPAN></B></EM><B><I><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><BR></SPAN></I></B><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">--Seen while the client is sending the request the underlying TCP connection was closed. <o:p></o:p></SPAN></P>
<P><EM><B><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">"The underlying connection was closed:&nbsp; The server committed an HTTP protocol violation." </SPAN></B></EM><B><I><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><BR></SPAN></I></B><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">--Seen when the HTTP response from the server was deemed incorrect or not conforming to the guidelines specified in HTTP 1.1 RFC (<A href="https://www.w3.org/Protocols/rfc2616/rfc2616.html" mce_href="https://www.w3.org/Protocols/rfc2616/rfc2616.html"><SPAN style="COLOR: #ffff99">https://www.w3.org/Protocols/rfc2616/rfc2616.html</SPAN></A>). May occur if the .Net client considers the response to be a security threat, as well. <o:p></o:p></SPAN></P>
<P><EM><B><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">"The underlying connection was closed: Could not establish secure channel for SSL/TLS."</SPAN></B></EM><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><BR>--Seen when the client could not successfully establish SSL/TLS channel, for HTTPS request. Usually caused by invalid/expired client or server SSL certificates. <o:p></o:p></SPAN></P>
<P><EM><B><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">"The operation has timed-out"</SPAN></B></EM><B><I><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><BR></SPAN></I></B><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">--Seen when the client timeout value expired before the server response came in. Though this is not an underlying connection closed error, the following suggestions help in addressing this. <o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">Please refer <A href="https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetwebexceptionstatusclasstopic.asp" mce_href="https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetwebexceptionstatusclasstopic.asp"><SPAN style="COLOR: #ffff99">https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetwebexceptionstatusclasstopic.asp</SPAN></A> for determining the status when getting a WebException.<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">The following are also very helpful in effectively resolving or working around 'Underlying connection closed' errors. <o:p></o:p></SPAN></P>
<P><STRONG><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">1. Ensure your .Net framework is up to date:</SPAN></STRONG><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><BR>==================================<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">Typically applying SP1 for .Net framework 1.1, which is included in Windows 2003 Server SP1, should resolve most known bugs/issues with incorrect TCP behaviour. If your application is using SSL for the HTTP request, I strongly recommend applying SP1 for .Net framework (or on a Windows 2003 Server, you may apply SP1 for the OS). <o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">Once you apply, confirm that SP1 for .Net framework is correctly installed. To do this, you can check the registry key as per the following KB article.<BR>318785 Determine whether service packs are installed on the .NET Framework<BR><A href="https://support.microsoft.com/?id=318785" mce_href="https://support.microsoft.com/?id=318785"><SPAN style="COLOR: #ffff99">https://support.microsoft.com/?id=318785</SPAN></A><o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">Doing this may address: <BR>--------------------------------<BR>All the above exceptions<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><BR><STRONG><SPAN style="FONT-FAMILY: Arial">2. Ensure that HttpWebRequest settings are appropriate for the requests issued:</SPAN></STRONG><B><BR></B>===============================================================<BR>Note that the default connections recommended for a HTTP 1.1 client is 2 and that is the default with HttpWebRequest. If your application requires more than two concurrent connections then you will have to increase the number of concurrent connections HttpWebRequest can use. If <BR>&nbsp;&nbsp; (a) number of connections is not increased, <BR>&nbsp;&nbsp; (b) both concurrent connections are busy and <BR>&nbsp;&nbsp; (c) if there are pending requests which do not get a chance to use a connection, <BR>then the pending requests may get a "The operation has timed-out" exception. <o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">Note: If you are making a request from ASP.Net code, since the ASP.Net application is a service and may have to have more than 2 connections for handling incoming requests, increasing concurrent connections for HttpWebRequest is recommended.<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">Note: The webservice reference proxy code, generated by Visual Studio WSDL.exe tool (which is used when you add a webreference to a C# or VB.Net project) uses System.Net.HttpWebRequest to make the HTTP requests. So if you are seeing underlying connection closed errors on a webservice call, you will have to confirm that your webservice client code/configuration is tuned as for System.Net.HttpWebRequest.<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">To increase number of concurrent connections, increase ServicePointManager.DefaultConnectionLimit property starting at 12 per processor as per the following MSDN article: <BR><A href="https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemNetServicePointManagerClassDefaultConnectionLimitTopic.asp" mce_href="https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemNetServicePointManagerClassDefaultConnectionLimitTopic.asp"><SPAN style="COLOR: #ffff99">https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemNetServicePointManagerClassDefaultConnectionLimitTopic.asp</SPAN></A> <o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">Note: Please ensure that any change in default values for ServicePointManager properties is done before any HTTP request is sent out.<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">If you want to set it in a config file, and not through code, use the &lt;connectionManagement&gt; Element as per the following MSDN article:<BR><A href="https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gngrfconnectionmanagementelement.asp" mce_href="https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gngrfconnectionmanagementelement.asp"><SPAN style="COLOR: #ffff99">https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gngrfconnectionmanagementelement.asp</SPAN></A> <BR>The &lt;connectionManagement&gt; element defines the maximum number of connections to a server or group of servers.<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">Doing this may address: <BR>---------------------------------<BR>"The operation has timed-out" exception<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><BR><STRONG><SPAN style="FONT-FAMILY: Arial">3. KeepAlive connection issues:</SPAN></STRONG><BR>=========================<BR>We could see the problem if the Keep Alive connection is not correctly handled by .Net client process or the WebServer. <BR>Note: KeepAlive is required for NTLM and Kerberos authentication. So if you are NOT using NTLM or Kerberos as authentication and NOT require Keep Alive for the connection, you can try setting KeepAlive to false. <o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">For setting Timeout in HttpWebRequest object: <A href="https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnethttpwebrequestclasstimeouttopic.asp" mce_href="https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnethttpwebrequestclasstimeouttopic.asp"><SPAN style="COLOR: #ffff99">https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnethttpwebrequestclasstimeouttopic.asp</SPAN></A><BR>For setting Timeout from a webservice client: <BR>&nbsp;&nbsp; 1. Create a new class by inheriting from the generated proxy class. <BR>&nbsp;&nbsp; 2. Add the following method to override GetWebRequest method to access the underlying HttpWebRequest object.<BR>&nbsp;&nbsp; C#:<BR>&nbsp;&nbsp;&nbsp; protected override WebRequest GetWebRequest(Uri uri)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HttpWebRequest webRequest = (HttpWebRequest) base.GetWebRequest(uri);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Setting KeepAlive to false<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; webRequest.KeepAlive = false;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return webRequest;<BR>&nbsp;&nbsp;&nbsp; }<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">&nbsp;&nbsp; VB.Net:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Protected Overrides Function GetWebRequest(ByVal uri As Uri) As System.Net.WebRequest<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim webRequest As System.Net.HttpWebRequest<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; webRequest = CType(MyBase.GetWebRequest(uri), System.Net.HttpWebRequest)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Setting KeepAlive to false <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; webRequest.KeepAlive = False<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GetWebRequest = webRequest<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Function<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">Doing this may address: <BR>----------------------------------<BR>"The underlying connection was closed: An unexpected error occurred on a Send."&nbsp; and "The underlying connection was closed: An unexpected error occurred on a receive." exceptions<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><BR><STRONG><SPAN style="FONT-FAMILY: Arial">4. For closing a KeepAlive connection before server times out: </SPAN></STRONG><BR>===================================================<BR>If the server KeepAlive connection timeout is close to the client KeepAlive connection timeout, and if the client is sending a request on the connection almost at the end of timeout duration, then we may see "The underlying connection was closed: An unexpected error occurred on a Send."&nbsp; and "The underlying connection was closed: An unexpected error occurred on a receive." errors.<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">For this problem, we can try reducing the duration at which the client will actively purge the existing unused connection through ServicePointManager.MaxServicePointIdleTime Property. <BR>Please refer <A href="https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetservicepointmanagerclassmaxservicepointidletimetopic.asp" mce_href="https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetservicepointmanagerclassmaxservicepointidletimetopic.asp"><SPAN style="COLOR: #ffff99">https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetservicepointmanagerclassmaxservicepointidletimetopic.asp</SPAN></A>. <o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><BR>Please try setting this value less than the server KeepAlive connection timeout. <o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">Note: Please ensure that any change in default values for ServicePointManager properties is done before any HTTP request is sent out.<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">Doing this may address: <BR>---------------------------------<BR>"The underlying connection was closed: An unexpected error occurred on a Send."&nbsp; and "The underlying connection was closed: An unexpected error occurred on a receive." exceptions<BR>&nbsp;<o:p></o:p></SPAN></P>
<P><STRONG><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">5. Setting ASP.Net executionTimeout if client code is in ASP.Net:</SPAN></STRONG><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"> <BR>==================================================<BR>If your client code is running in ASP.Net, please make sure that your timeouts are implemented as specified below. The ASP.Net process executionTimeout and the webservice client call timeout should be set as per the following article. <o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">904262 The request that is sent by the HttpWebRequest class may stop responding<BR><A href="https://support.microsoft.com/?id=904262" mce_href="https://support.microsoft.com/?id=904262"><SPAN style="COLOR: #ffff99">https://support.microsoft.com/?id=904262</SPAN></A><o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">Ensure that your ASP.Net webservice client timeout MUST be higher than the maximum time taken by the webservice to respond for longest running request. <o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">Doing this may address: <BR>--------------------------------<BR>"The operation has timed-out"&nbsp; and "The underlying connection was closed: An unexpected error occurred on a receive." exceptions<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><BR><STRONG><SPAN style="FONT-FAMILY: Arial">6. Ensure proxy settings are correct:</SPAN></STRONG><BR>===========================<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">You can use the static method WebProxy.GetDefaultProxy as per <A href="https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetwebproxyclassgetdefaultproxytopic.asp" mce_href="https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetwebproxyclassgetdefaultproxytopic.asp"><SPAN style="COLOR: #ffff99">https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetwebproxyclassgetdefaultproxytopic.asp</SPAN></A>, or you can use <A href="https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gngrfproxyelement.asp" mce_href="https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gngrfproxyelement.asp"><SPAN style="COLOR: #ffff99">https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gngrfproxyelement.asp</SPAN></A> for defining &lt;proxy&gt; element in .config files. <o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">If your environment is configured for autoproxy, refer the following.<BR>873199 How to use autoproxy in managed code<BR><A href="https://support.microsoft.com/?id=873199" mce_href="https://support.microsoft.com/?id=873199"><SPAN style="COLOR: #ffff99">https://support.microsoft.com/?id=873199</SPAN></A><o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">Doing this may address: <BR>--------------------------------<BR>"The underlying connection was closed: Unable to connect to the remote server." exception<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><BR><STRONG><SPAN style="FONT-FAMILY: Arial">7. Ensure that the server (where client code is running) does not have protocol binding limitations issue:</SPAN></STRONG><B><BR></B>================================================================================<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">826757 FIX: Socket Initialization Does Not Succeed if Your Computer Has More<BR><A href="https://support.microsoft.com/?id=826757" mce_href="https://support.microsoft.com/?id=826757"><SPAN style="COLOR: #ffff99">https://support.microsoft.com/?id=826757</SPAN></A><o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">This fix is included in .Net framework 1.1 SP1 and also in Windows 2003 SP1. If this is the cause, any System.Net socket application will fail. <o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">Doing this may address: <BR>---------------------------------<BR>"The operation has timed-out"&nbsp; and "The underlying connection was closed: Unable to connect to the remote server." exceptions<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><BR><STRONG><SPAN style="FONT-FAMILY: Arial">8. Problems in establishing SSL/TLS channels:</SPAN></STRONG><BR>====================================<BR>First verify that the server and client (if any) SSL certificates are valid, not expired and can be used from browser without any problems. <o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">The following explain how to use SSL with client certificates with .Net framework.<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">901183 How to call a Web service by using a client certificate for<BR><A href="https://support.microsoft.com/?id=901183" mce_href="https://support.microsoft.com/?id=901183"><SPAN style="COLOR: #ffff99">https://support.microsoft.com/?id=901183</SPAN></A><o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><A href="https://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT13.asp" mce_href="https://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT13.asp"><SPAN style="COLOR: #ffff99">https://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT13.asp</SPAN></A><o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><BR><A href="https://msdn.microsoft.com/library/en-us/dnnetsec/html/SecNetHT14.asp?frame=true" mce_href="https://msdn.microsoft.com/library/en-us/dnnetsec/html/SecNetHT14.asp?frame=true"><SPAN style="COLOR: #ffff99">https://msdn.microsoft.com/library/en-us/dnnetsec/html/SecNetHT14.asp?frame=true</SPAN></A><o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><BR>895971 How to send a client certificate by using the HttpWebRequest and<BR><A href="https://support.microsoft.com/?id=895971" mce_href="https://support.microsoft.com/?id=895971"><SPAN style="COLOR: #ffff99">https://support.microsoft.com/?id=895971</SPAN></A><o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">If the problem is caused by server SSL certificate (expired, untrusted CA or common name mismatch) and if the server is trusted, the errors can be ignored by using ICertificatePolicy.CheckValidationResult method (<A href="https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemNetICertificatePolicyClassCheckValidationResultTopic.asp" mce_href="https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemNetICertificatePolicyClassCheckValidationResultTopic.asp"><SPAN style="COLOR: #ffff99">https://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemNetICertificatePolicyClassCheckValidationResultTopic.asp</SPAN></A>). Please note that ignoring SSL certificate warnings in code is a possible security threat, unless the server is completely trusted. <o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">Doing this may address: <BR>----------------------------------<BR>"The underlying connection was closed: Could not establish secure channel for SSL/TLS." exception<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><BR><STRONG><SPAN style="FONT-FAMILY: Arial">9. Server response not conforming to HTTP RFC:</SPAN></STRONG><B><BR></B>======================================<BR>.Net framework 1.1 HTTP clients strictly follow HTTP 1.1 RFC guidelines in <A href="https://www.w3.org/Protocols/rfc2616/rfc2616.html" mce_href="https://www.w3.org/Protocols/rfc2616/rfc2616.html"><SPAN style="COLOR: #ffff99">https://www.w3.org/Protocols/rfc2616/rfc2616.html</SPAN></A>. If the server response to client does not fully comply with HTTP 1.1 RFC, the client will close the connection with the "The underlying connection was closed:&nbsp; The server committed an HTTP protocol violation." exception. Usually this happens with incorrect headers and header delimiters (<A href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6" mce_href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6"><SPAN style="COLOR: #ffff99">https://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6</SPAN></A>). The above exception is often seen after applying SP1 for .Net framework 1.1.<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">Any response not adhering with HTTP 1.1 RFC guideline, is considered as a security threat by .Net framework client, as allowing malformed headers may expose the client for "HTTP response splitting" attacks.<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">If the server is trusted completely, then the above exception can be worked around by following the KB article below, at the risk of compromising security. Please note that the best course of action for this exception would be to correct the server side application/webserver to send correct responses as per HTTP 1.1 RFC.<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><BR>892467 HttpWebRequest.GetResponse() returns "HTTP protocol violation" error<BR><A href="https://support.microsoft.com/?id=892467" mce_href="https://support.microsoft.com/?id=892467"><SPAN style="COLOR: #ffff99">https://support.microsoft.com/?id=892467</SPAN></A><o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial">Doing this may address: <BR>-----------------------------------<BR>"The underlying connection was closed:&nbsp; The server committed an HTTP protocol violation." exception<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 10pt; COLOR: #ffff99; FONT-FAMILY: Arial"><BR>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #ffff99"><o:p><FONT face="Times New Roman" size=3>&nbsp;</FONT></o:p></SPAN></P>
<P mce_keep="true">&nbsp;</P>]]></content:encoded>
    </item>
    <item>
      <title>Planning to add info on "Underlying connection was closed" errors.</title>
      <link>https://docs.microsoft.com/archive/blogs/engelsr/planning-to-add-info-on-underlying-connection-was-closed-errors</link>
      <pubDate>Tue, 29 Nov 2005 11:15:00 GMT</pubDate>
      <dc:creator><![CDATA[engelsr]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/engelsr/2005/11/29/planning-to-add-info-on-underlying-connection-was-closed-errors/</guid>
      <description><![CDATA[Planning to add information on "Underlying connection was closed" errors, until a KB article is...]]></description>
      <content:encoded><![CDATA[<P><FONT style="BACKGROUND-COLOR: #c0c0c0" color=#0000ff size=2>Planning to add information on "Underlying connection was closed" errors, until a KB article is written.</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #c0c0c0" color=#0000ff size=2>This is done. You can read the article here <A HREF="/engelsr/articles/497902.aspx">https://blogs.msdn.com/engelsr/articles/497902.aspx</A> </FONT></P>]]></content:encoded>
    </item>
  </channel>
</rss>