[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2009-05-08
2
Medium Priority
?
762 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
[X]
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
2 Comments
 
LVL 11

Accepted Solution

by:
Muhammad Ousama Ghazali earned 1500 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

656 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