472,995 Members | 1,547 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Problem with a growing number of connections in HttpWebRequest

Hi All!

I'm having a problem with a growing number of connections. my app
generates http requests and reads responses. the app creates large
number of threads (100 or more) that generates the requests, this is
the code:

ServicePointManager.DefaultConnectionLimit = 10;

ThreadFunction()
{
for(int i=0;i<1000000;i++)
{
HttpWebRequest request =
(HttpWebRequest)WebRequest.Create("http://localhost:8080/page.html");
request.KeepAlive = true;
System.IO.StreamReader reader = new
System.IO.StreamReader(request.GetResponse().GetRe sponseStream());
reader.ReadToEnd();
request.GetResponse().Close();
}
}

I'm using TCPView to monitor connections, after a couple of minutes
connections number starts to increase gradually , and some connections
closes.
decreasing ServicePointManager.MaxServicePointIdleTime will result in
creating more connection in less time

Is this problem is an issue of freeing resources? garbage collection?
My goal is to let each thread open one connection and stay active along
the way.

And what is the best way to achieve maximal throughput?

Basel

May 21 '06 #1
2 2432
Basel,

You know that there is a commitment that says that there should not be used
more than 4 HTTP connections at a time in an applications and as this set in
PC Operatingsystems as default?

Cor

"Basel" <ba****@gmail.com> schreef in bericht
news:11**********************@y43g2000cwc.googlegr oups.com...
Hi All!

I'm having a problem with a growing number of connections. my app
generates http requests and reads responses. the app creates large
number of threads (100 or more) that generates the requests, this is
the code:

ServicePointManager.DefaultConnectionLimit = 10;

ThreadFunction()
{
for(int i=0;i<1000000;i++)
{
HttpWebRequest request =
(HttpWebRequest)WebRequest.Create("http://localhost:8080/page.html");
request.KeepAlive = true;
System.IO.StreamReader reader = new
System.IO.StreamReader(request.GetResponse().GetRe sponseStream());
reader.ReadToEnd();
request.GetResponse().Close();
}
}

I'm using TCPView to monitor connections, after a couple of minutes
connections number starts to increase gradually , and some connections
closes.
decreasing ServicePointManager.MaxServicePointIdleTime will result in
creating more connection in less time

Is this problem is an issue of freeing resources? garbage collection?
My goal is to let each thread open one connection and stay active along
the way.

And what is the best way to achieve maximal throughput?

Basel

May 22 '06 #2
I know that single-user should not maintain more than 2 persistent
connections with any server or proxy.

Anyway, I dont think this should affect my application, I set the web
server not to limit connections. the server is in my lan.
Also, if I open only 2 connection, the number of the connections will
grow after some time.
So the problem is not with the number of connections I open.

May 22 '06 #3

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

Similar topics

2
by: msnews.microsoft.com | last post by:
Hello everyone I was wondering if anyone has come across my problem? I programmed a Windows Service that uses httpWebRequest and httpWebResponse in VB.NET. Everything works fine until I use the...
7
by: David Sworder | last post by:
Hi, I'm developing an application that will support several thousand simultaneous connections on the server-side. I'm trying to maximize throughput. The client (WinForms) and server communicate...
5
by: japslam japslam via DotNetMonster.com | last post by:
Hi all, I have problem when I use HttpWebRequest and take long time to call to my service server. If at that time there are many request comes in semultaneous, I will get this exception ...
10
by: Basel | last post by:
Hi All, I'm opening a number of threads, and each thread generates http requests using HttpWebRequest. How to make each thread open only 1 connection ? I tried to set a unique...
2
by: Dan D. | last post by:
Let me say first that I don't know much about .NET. We inherited an app from a group of developers and we have a second group of contractors working on the app. The first group set min=100 in the...
0
by: buccsailor | last post by:
Hell there, I tried to post a reply to a message thread created back in July 2006 regarding the override of WebRequest, Closed Conenctions and setting KeepAlive to false,but it's been over 60...
1
by: sherifbk | last post by:
Problem description ============== - I have 4 clients and 1 server (SQL server) - 3 clients are Monitoring console 1 client is operation console - Monitoring console collects some data from...
8
by: Chizl | last post by:
I'm building a web server and having some issues with the TCPListener.Start(BackLog). It doesn't seem to do as expected. I'm using MS Web Stress Tool to test against my web server and when I...
2
by: dantz | last post by:
Having a multiple client/server using a C# httplistener/httpwebrequest to transfer message. How should I handle idle connections? Will it be the job of the server or client? Does using a ping...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.