Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Getting "underlying connection was closed..." error on HttpWebRequest()

Posted on 2009-05-08
2
746 Views
Last Modified: 2013-12-17
We have a console application using HttpWebRequest on Win Server with .net 3.5. Intermittently, we get errors :

  The underlying connection was closed: An unexpected error occurred on a send. 

How can we correct this ?

Any advantage in adding ServicePointManager.MaxServicePoints and ServicePointManager.MaxServicePointIdleTime ?

Where would these be set  ?

Thank you,
Gary Davis
 
HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(&.);
webReq.Method = "POST";
webReq.ContentType = "text/xml";
webReq.Headers.Add("Authorization", "Basic " + strAccount);
webReq.AuthenticationLevel = System.Net.Security.AuthenticationLevel.None;
webReq.KeepAlive = false;
 
HttpWebResponse webResp = (HttpWebResponse)webReq.GetResponse();
 
Stream stream = webResp.GetResponseStream() as Stream;
byte[] buffer = new byte[32 * 1024];
int nRead = 0;
MemoryStream ms = new MemoryStream();
 
do
{
 nRead = stream.Read(buffer, 0, buffer.Length);
 ms.Write(buffer, 0, nRead);
} while (nRead > 0);

Open in new window

0
Comment
Question by:Gary Davis
2 Comments
 
LVL 11

Accepted Solution

by:
Muhammad Ousama Ghazali earned 500 total points
ID: 24348255
The problem you are facing has been officially documented by Microsoft here: http://support.microsoft.com/default.aspx?scid=kb;EN-US;915599

For additional support, you may see this link too: http://weblogs.asp.net/jan/archive/2004/01/28/63771.aspx
0
 
LVL 18

Author Comment

by:Gary Davis
ID: 24400216
I have reviewed the sources and I am still seeing occasional issues so will try some different possibilities. I am closing this in any case.
Thanks
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question