473,405 Members | 2,404 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,405 software developers and data experts.

Limitations in HttpWebRequest ?

Hi,

I am trying to get continous streams of data from the same web server using
this sample code. It works fine if i starts two threads from the same program
which continously stream different data from the same webserver, but as soon
as i start the third streama gainst the same webserver in a new thread i keep
getting timouts from the webrequest. If i start other streams (up to 25) from
other web servers i have no problems. So is there any known limitation in how
many streams i can do against the same webserver ? and any known workaround ?

Rgds, Henrik

---

wrs = (HttpWebRequest)WebRequest.Create(SomeURL);
wrs.Credentials = myCred;
wst = (HttpWebResponse)wrs.GetResponse();
str = wst.GetResponseStream();

Nov 16 '05 #1
2 1788
Often 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.
Here is an example:

for(int i=0; i < 3; i++) {
HttpWebRequest r = WebRequest.Create("http://www.yahoo.com") as
HttpWebRequest;
HttpWebResponse w = r.GetResponse() as HttpWebResponse;
}

In the above, the third request will hang in GetResponse().

If you close the response, by calling Response.Close() ,
then the underlying connection gets freed up, and the request will succeed.
--Peter
"Henrik" <He****@discussions.microsoft.com> wrote in message
news:7C**********************************@microsof t.com...
Hi,

I am trying to get continous streams of data from the same web server using this sample code. It works fine if i starts two threads from the same program which continously stream different data from the same webserver, but as soon as i start the third streama gainst the same webserver in a new thread i keep getting timouts from the webrequest. If i start other streams (up to 25) from other web servers i have no problems. So is there any known limitation in how many streams i can do against the same webserver ? and any known workaround ?
Rgds, Henrik

---

wrs = (HttpWebRequest)WebRequest.Create(SomeURL);
wrs.Credentials = myCred;
wst = (HttpWebResponse)wrs.GetResponse();
str = wst.GetResponseStream();

Nov 16 '05 #2
Peter Bromberg [MVP] wrote:
Often 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. Here is an example:

for(int i=0; i < 3; i++) {
HttpWebRequest r = WebRequest.Create("http://www.yahoo.com") as
HttpWebRequest;
HttpWebResponse w = r.GetResponse() as HttpWebResponse;
}

In the above, the third request will hang in GetResponse().

If you close the response, by calling Response.Close() ,
then the underlying connection gets freed up, and the request will
succeed. --Peter


That's technically correct, but the reason why this happens from a
design point of view is that the number of HTTP connections a client
can establish with any given host is limited by an URI's service point
(*). See System.Net.ServicePoint and System.Net.ServicePointManager for
more details.

(*) see http://www.w3.org/Protocols/rfc2616/...sec8.html#sec8 for
more details.

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 16 '05 #3

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

Similar topics

5
by: Dan Battagin | last post by:
Is there a known bug with the interaction between the HttpWebRequest and the ThreadPool? I current spawn several HttpWebRequest's using BeginGetResponse, and they work for a while, using worker...
10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
9
by: Mike Cronin via DotNetMonster.com | last post by:
Hi there, Can anyone tell me what level of encryption is used when making an HTTPS POST request through an instance of the System.Net.HttpWebRequest object? Thanks much in advance! Mike...
1
by: Brad | last post by:
I have written a process in C# that uses the httpwebrequest to retrieve jpg images.
16
by: thomas peter | last post by:
I am building a precache engine... one that request over 100 pages on an remote server to cache them remotely... can i use the HttpWebRequest and WebResponse classes for this? or must i use the...
1
by: sfoxover | last post by:
Hi, Could someone please give me some suggestions on how to make this class robust. I need to be able to handle around 20 similtanious requests to this class which causes a web browser to...
6
by: Mike Koerner | last post by:
Hi, I am having problems setting the HttpWebRequest Date header. I understand that it is a restricted header and I do receive the "This header must be modified with the appropriate property." ...
3
by: JansenH | last post by:
We have implemented a 'HTTP Post' client in C# that posts Xml documents to a webserver. This is working fine if the post rate is one post for every 20 seconds. But if the post rate is increased to...
1
by: Proogeren | last post by:
I have a problem with a httpwebrequest that I am creating. The request in itself looks correct but using fiddler I see that a www-authentication header is sent along as well. The code is pasted...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
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...
0
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...
0
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...

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.