473,806 Members | 2,878 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

webreq.getrespo nse exceptions

cj
VB 2003
I have a programs that accepts TCPIP requests and processes them. A
thread is created to handle each TCPIP connection. Part of handling the
request is involves making a webrequest.

webReq = Net.HttpWebRequ est.Create(URL)
webReq.Timeout = 60000
webResp = webReq.GetRespo nse

This has been working fine for 6 months or more handling maybe 50
simultaneous requests but now the traffic has picked up substantially.
It might be handling 150 requests simultaneously. I'm beginning to get
exceptions thrown making the web request. I get either of these

The operation has timed-out.
The underlying connection was closed: The request was canceled.

The operation has timed-out exception is probably because it went over 1
minute and I have to have some sort of timeout because the TCPIP request
I got initially is waiting on it's reply and will not wait for long.

I don't know if the second exception is something I can do anything
about or if it is web server related. Any ideas?
Oct 28 '06 #1
4 1664
Hi cj,

Based on the code snippet you have provided, I didn't see the code that
you're closing the underlying connection. Usually, people forget that the
underlying connection created by the request is not freed up,unless you
call Close() on the response. So, you hit the connection limit, and no more
webrequests will go through. Please call Response.Close( ) to close it when
it is used.

You can check the following link for more information.

http://blogs.msdn.com/feroze_daud/ar.../21/61400.aspx

If this still doesn't help, you may be facing a performance issue for your
ASP.NET app. Please check the following KB article for how to do
performance tuning on this issue.

http://support.microsoft.com/kb/821268/en-us

Kevin Yu
Microsoft Online Community Support

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Oct 30 '06 #2
cj
Kevin,

Yes, I close the connection. I only wanted to show the command I used
to contact the server.

Also I'm told the server I'm contacting has no set limit on it's
connections.

My program, this one we are talking about, is not ASP.NET. I guess you
know that. It is just a Windows program. I believe the web server is
running ASP.NET code and that could be the problem but I didn't write
that program. If you have suggestions on what the problem could be on
the web server side I can pass them on to the folks working on that program.

Here a small section of my actual code.
Try
Dim webReq As Net.HttpWebRequ est
Dim webResp As Net.HttpWebResp onse
Dim URL As String =
"http://192.168.168.142/validate/validate.aspx?" & _
iElement(3) & _
"&submit_by =R" & _
"&" & iElement(2)

webRespStr = ""
webReq = Net.HttpWebRequ est.Create(URL)
webReq.Timeout = 15000
Try
webResp = webReq.GetRespo nse
Catch ex As Exception
LoopErrMsg += (deleted extra stuff here
for this email)
End Try

webResp.Close()

(deleted extra stuff here for this email)

Catch ex As Exception
LoopErrMsg += (deleted extra stuff here for
this email)
End Try

Kevin Yu [MSFT] wrote:
Hi cj,

Based on the code snippet you have provided, I didn't see the code that
you're closing the underlying connection. Usually, people forget that the
underlying connection created by the request is not freed up,unless you
call Close() on the response. So, you hit the connection limit, and no more
webrequests will go through. Please call Response.Close( ) to close it when
it is used.

You can check the following link for more information.

http://blogs.msdn.com/feroze_daud/ar.../21/61400.aspx

If this still doesn't help, you may be facing a performance issue for your
ASP.NET app. Please check the following KB article for how to do
performance tuning on this issue.

http://support.microsoft.com/kb/821268/en-us

Kevin Yu
Microsoft Online Community Support

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Oct 30 '06 #3
cj
Ooops, I deleted a line by accident when removing extra junk from my
code to post. just before webresp.close() is the line

webrespstr = new io.streamreader (webresp.getres ponsestream).re adtoend
Sorry for the confusion.

cj wrote:
Kevin,

Yes, I close the connection. I only wanted to show the command I used
to contact the server.

Also I'm told the server I'm contacting has no set limit on it's
connections.

My program, this one we are talking about, is not ASP.NET. I guess you
know that. It is just a Windows program. I believe the web server is
running ASP.NET code and that could be the problem but I didn't write
that program. If you have suggestions on what the problem could be on
the web server side I can pass them on to the folks working on that
program.

Here a small section of my actual code.
Try
Dim webReq As Net.HttpWebRequ est
Dim webResp As Net.HttpWebResp onse
Dim URL As String =
"http://192.168.168.142/validate/validate.aspx?" & _
iElement(3) & _
"&submit_by =R" & _
"&" & iElement(2)

webRespStr = ""
webReq = Net.HttpWebRequ est.Create(URL)
webReq.Timeout = 15000
Try
webResp = webReq.GetRespo nse
Catch ex As Exception
LoopErrMsg += (deleted extra stuff here
for this email)
End Try

webResp.Close()

(deleted extra stuff here for this email)

Catch ex As Exception
LoopErrMsg += (deleted extra stuff here for
this email)
End Try

Kevin Yu [MSFT] wrote:
>Hi cj,

Based on the code snippet you have provided, I didn't see the code
that you're closing the underlying connection. Usually, people forget
that the underlying connection created by the request is not freed
up,unless you call Close() on the response. So, you hit the connection
limit, and no more webrequests will go through. Please call
Response.Close () to close it when it is used.

You can check the following link for more information.

http://blogs.msdn.com/feroze_daud/ar.../21/61400.aspx

If this still doesn't help, you may be facing a performance issue for
your ASP.NET app. Please check the following KB article for how to do
performance tuning on this issue.

http://support.microsoft.com/kb/821268/en-us

Kevin Yu
Microsoft Online Community Support

============== =============== =============== ======
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif

ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues where an initial response from the community or a Microsoft
Support Engineer within 1 business day is acceptable. Please note that
each follow up response may take approximately 2 business days as the
support professional working with you may need further investigation
to reach the most efficient resolution. The offering is not
appropriate for situations that require urgent, real-time or
phone-based interactions or complex project analysis and dump analysis
issues. Issues of this nature are best handled working with a
dedicated Microsoft Support Engineer by contacting Microsoft Customer
Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
============== =============== =============== ======

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Oct 30 '06 #4
Hi cj,

Based on my experience, this has to be a server side issue. The web server
cannot support so many concurrent requests.

Although you have check that IIS doesn't have a limitation on connections,
the ASP.NET has some limitations set in the configuration file. I think you
have to tune the performance on the server according to the following KB
article

http://support.microsoft.com/kb/821268/en-us

This article is for ASP.NET 1.1. However, you can also use this in ASP.NET
2.0. The 2.0 machine.config file doesn't have the default value set. You
can add the keys and values manually.

Kevin Yu
Microsoft Online Community Support
=============== =============== =============== =====

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Oct 31 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
6152
by: Jonathan | last post by:
Calling the System.Net.WebResponse.GetResponse method (see code below) results in the following error: System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. at(System.Net.HttpWebRequest.CheckFinalStatus()) at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at(System.Net.HttpWebRequest.GetResponse())
1
12613
by: Jeff B | last post by:
I'm trying to create a simple screen scraping application and I kept getting a System.Net.WebException thrown back with a message of "The operation has timed-out." At first I thought it was some kind of connectivity issue on the machine. It didn't make sense though, because I can open up a browser on the same machine and easily browse the web. I'm stumped. I looked over my code for any errors and just couldn't find what I was doing...
4
7238
by: Terry | last post by:
Hello, I am trying to get a response for an .aspx page in my current project (same virtual directory) by using WebRequest.GetResponse but I keep getting a exception with "500 Internal server error" in the exception message. I am able to do this fine with another .aspx page that has no code-behind. The page that has code-behind throws the exception. What I am doing is getting the .aspx response, reading the stream, replacing
2
14099
by: Steve Richter | last post by:
I have a page that uses simple HTTP GET to do an ISBN lookup via Amazon.com. The page works when I run it from //localhost. But I have moved it to my godaddy.com shared hoster site, and I get errors on the HttpWebRequest.GetResponse statement. The remote server returned an error: (401) Unauthorized also, when I use the network credentials object in the context of my request, I get this error:
2
20178
by: GlennLanier | last post by:
Hello, I've searched the forums and can't find an answer -- if it i there, kindly point me in that direction. I would like to simulate a browser POSTing a FORM and be able to pars the response. I have the following code in my Page_Load (litResponse is defined a <ASP:Literal>):
2
4895
by: microdevsolutions | last post by:
Hello I've seen examples to read a file from somewhere into a HttpWebRequest object then write it to a HttpWebResponse object then stream it into a Stream object, very similar to the following code snipet :- ============================================== Uri uri = new Uri("http://www.somewhere/pdf/image1.pdf"); HttpWebRequest httpRequest = null;
4
1752
by: JezB | last post by:
I do some peeking at files on the web in my program with code such as: WebRequest wr = WebRequest.Create(url); WebResponse r = wr.GetResponse(); I've noticed that the first time GetResponse is executed, it takes some 3 to 4 seconds. Repeating the same code in the same run is almost immediate. So why the delay the first time this is executed on each run? And can I do anything about it?
8
13584
by: Morgan Cheng | last post by:
I happens to surf to http://www.codeproject.com/cs/internet/Crawler.asp, which claims that WebRequest.GetResponse() will block other thread calling this function until WebResponse.Close() is called. I did some experimentation. public static void Main(string args) { for (int idx=0; idx<10; ++idx)
5
4872
by: mr.newsgroupguy | last post by:
I am working in C# .NET 1.1. My app has a button on its main form that checks to see if it has access to a file on our server, just an XML file. On our server we are running W2K IIS with a virtual directory, set to Windows Authentication. I am creating an HTTPWebRequest object on the client, and setting its Credentials to CredentialCache.DefaultCredentials. Also, I have tried numerous Timeout settings, but they have not made a...
0
9597
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10618
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10371
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4329
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3850
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.