473,323 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

webreq.getresponse 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.HttpWebRequest.Create(URL)
webReq.Timeout = 60000
webResp = webReq.GetResponse

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 1630
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.HttpWebRequest
Dim webResp As Net.HttpWebResponse
Dim URL As String =
"http://192.168.168.142/validate/validate.aspx?" & _
iElement(3) & _
"&submit_by=R" & _
"&" & iElement(2)

webRespStr = ""
webReq = Net.HttpWebRequest.Create(URL)
webReq.Timeout = 15000
Try
webResp = webReq.GetResponse
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.getresponsestream).readtoe nd
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.HttpWebRequest
Dim webResp As Net.HttpWebResponse
Dim URL As String =
"http://192.168.168.142/validate/validate.aspx?" & _
iElement(3) & _
"&submit_by=R" & _
"&" & iElement(2)

webRespStr = ""
webReq = Net.HttpWebRequest.Create(URL)
webReq.Timeout = 15000
Try
webResp = webReq.GetResponse
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
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...
1
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...
4
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...
2
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...
2
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....
2
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...
4
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...
8
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...
5
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.