Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Persistent Connection of HTTP/1.1 with WinHttpRequest 5.0

936 views
Skip to first unread message

Fatty

unread,
Aug 23, 2004, 3:40:11 AM8/23/04
to
Hi,

I am using WinHttpRequest5.0 in my ASP to make request to another IIS
(with keepalive enabled). I monitor the tcp connection with netstat
(in the PC hosting ASP) everytime after I made a request.
I did twice quickly.

In 1st netstate:
Proto Local Address(my ASP) Foreign Address(another IIS)
State
TCP 13.456.789.11:3008 13.456.568.113:1690
ESTABLISHED
TCP 13.456.789.11:3008 13.456.568.113:1690
TIME_WAIT (1-2 secound,ie.after my ASP got response)

From the http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=uj9eNWIHCHA.2644%40tkmsftngp11,
I know that WinHttp do connection pooling and reuse automatically.
So I expect the port 3008 and 3010 will be reused in 2nd http request.
However, it didn't. A new port was created and port 3008 was still
at TIME_WAIT state.
I check the IIS log and confirm that HTTP/1.1 was used.

Would you please tell me why?

Thanks.

Biao Wang [MSFT]

unread,
Aug 24, 2004, 3:15:01 AM8/24/04
to
Hi,

Can you either take a network sniff (e.g. using netmon) or use the
winhttptracecfg.exe tool to capture a trace? Please check whether the server
include a "Connection: Close" header in its response.

Also did you read all the response data before sending the second request? A
connection will not be pooled if there are un-read data left in it.

Hope this helps,
Biao.W. [MSFT]

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

Fatty

unread,
Aug 30, 2004, 9:43:55 PM8/30/04
to
Wang,

Thank you very much for your reply.
I will use network sniff to check if "Connection: Close" are set in
header.
For your second question, I am sure that all data are read before
sending second request.

Besides, would you please advise how I can set the TCP connection
pooling size by WinHttpRequest? Or is it controlled by other
parameters (such as AspProcessorThreadMax) on IIS?


"Biao Wang [MSFT]" <BiaoWa...@discussions.microsoft.com> wrote in message news:<7A0BD9F1-2C88-40B2...@microsoft.com>...

Stephen Sulzer

unread,
Sep 3, 2004, 1:50:52 AM9/3/04
to
There is no way to control the size of the connection pool that a
WinHttpRequest object manages. (WinHttpRequest objects share a single pool
of connections for anonymous HTTP requests.)

If you are using the WinHTTP Win32 API, there are per-session options
(WINHTTP_OPTION_MAX_CONNS_PER_SERVER,
WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER) to control the size of the
connection pool. The default setting is that there is no limit imposed on
the number of connections in the pool.

The number of connections (to a given server) in the pool will typically
equal the maximum number of simultaneous requests that the application sends
to that server. So, for example, if the application sends six HTTP requests
at the same time to a server, WinHTTP will create six connections and then
put them in the pool, available for re-use. If the applications sends the
six HTTP requests one at a time, then WinHTTP will only need to create one
connection.

Stephen


"Fatty" <micha...@yahoo.com.hk> wrote in message
news:2e0ab560.04083...@posting.google.com...

Fatty

unread,
Sep 26, 2004, 9:10:35 PM9/26/04
to
Thanks Stephen.

What do you mean "simultaneous requests"? Do you mean that HTTP
requests sent in "SAME" ASP are simultaneous requests?

Thanks.

What is the timeout value of a established TCP Connection?

"Stephen Sulzer" <sasulzer_at_seanet.com> wrote in message news:<10jg1i1...@corp.supernews.com>...

Stephen Sulzer

unread,
Sep 29, 2004, 5:57:05 AM9/29/04
to

"Simultaneous requests" - the number of HTTP requests that the process is
sending concurrently (e.g., across multiple threads at the same time) to the
same target server.

So suppose you have an ASP page that uses WinHTTP to send an HTTP request to
a target server called "A", for example. If five clients access your server
at once, causing the ASP page to run for each client, your IIS/ASP server
may run that ASP page concurrently across five threads. Each thread will use
WinHTTP to send a request to server A. WinHTTP will create up to five socket
connections to server A.

As for the "timeout value of an established TCP connection," do you mean the
timeout of an idle TCP connection--that is, a socket sitting in the pool and
not being used--when will WinHTTP close it? That is quite tricky to
explain--it depends on what version of WinHTTP you are using and what your
application is doing. Roughly, WinHTTP will consider an idle socket in the
pool to be "expired" if the socket has not been used for about two minutes.
WinHTTP will not use an expired socket in subsequent HTTP requests; it will
be discarded. (Also, even if a socket has not "expired", the server may have
closed its side of the connection, forcing WinHTTP to discard the socket.)

Stephen


"Fatty" <micha...@yahoo.com.hk> wrote in message

news:2e0ab560.04092...@posting.google.com...

0 new messages