Hi Steven...
I'm still working on trying to get a smaller reproducible case, but I've
also tried to get some other statistics. I'm getting the impression that
both the ServicePoint on the client side and the HttpListener on the server
side are going to some lengths to obscure how many actual sockets you have
and how many requests are pipelined.
I'm thinking the one that's having problems is having it with some pipelining.
On the client side, I added statistics to show the time between
BeginGetRequestStream() and the requestStream.close() in the completion
routine - the time to get a connection and write the bytes up. Every now and
again, I see jumps of about 45 milliseconds; I'm guessing that the 45 ms is
the time to spin up a new socket to make a request.
As long as the client waits for a response to the question before sending
another request, the next request seems to re-use the same socket (transfer
time is 0 ms).
On one occasion, though, when the client fired 2 requests at once, it looks
like another socket is fired up for the 2nd request (it has the 45 ms lag).
My problem, though, is that it gets in a state again where the client sends
2 requests at once but the ServicePoint *doesn't* spin up a new socket.
Instead it waits until the first request is finished to pipeline the next
request and doesn't send the data until the first one clears.
So my question is slightly clarified to "How does one determine when a
request will be pipelined vs having a separate socket created?"
The packets are all about the same size and for the most part the protocol
being implemented (xmpp 0124) is call/response, but there are occasions where
some calls don't require an answer and some out-of-band data comes from the
server, piggy-backed in other requests. The extra out-of-band responses from
the server may spawn more concurrent requests.
Thanks
Mark
Thanks for your followup Mark,
Yes, if we can make the problem scenario simplified that will be much
helpful. Also, I've tried forwarding this question to some other dev
engineers related to the network component classes. However, since the
problem context maybe a bit complex to explain and the problem here also
include some context from a former thread(about httpwebrequest), I'm not
sure whether they'll 100% get the things we're investigating here. Anyway,
I'll inform you of any update I get from them.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we
can improve the support we provide to you. Please feel free to let my
manager know what you think of
the level of service provided. You can send feedback directly to my manager
at: msdnmg@microsoft.com.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: =?Utf-8?B?TWFyaw==?= <mmodrall@nospam.nospam>
>References: <65F4BD41-538D-414D-83FF-C2275B7637E8@microsoft.com>
<VYTyBqDgIHA.6844@TK2MSFTNGHUB02.phx.gbl>
>Subject: RE: Does HttpListener have the same quirk as HttpWebRequest
>Date: Tue, 11 Mar 2008 09:48:06 -0700
>Hi Steven...
>
[quoted text clipped - 35 lines]
>Thanks
>Mark
Steven Cheng - 14 Mar 2008 11:44 GMT
Hi Mark,
Just got some info from the dev engineer. He told me that for the question
on "the number of actual sockets that ServicePoint is managing", in this
case, the client requests can't be pipelined because they use the POST verb
which is not idempotent (http://tools.ietf.org/rfc/rfc2616.txt "8.1.2.2
Pipelining").
Regards,
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: stcheng@online.microsoft.com ("Steven Cheng")
>Organization: Microsoft
>Date: Wed, 12 Mar 2008 04:41:07 GMT
>Subject: RE: Does HttpListener have the same quirk as HttpWebRequest
>Thanks for your followup Mark,
>
[quoted text clipped - 79 lines]
>>Thanks
>>Mark
Mark - 19 Mar 2008 17:54 GMT
Hi Steven,
Thank you for persisting in this question, and I'm sorry I didn't check back
sooner to see your response.
> Just got some info from the dev engineer. He told me that for the question
> on "the number of actual sockets that ServicePoint is managing", in this
> case, the client requests can't be pipelined because they use the POST verb
> which is not idempotent (http://tools.ietf.org/rfc/rfc2616.txt "8.1.2.2
> Pipelining").
I read the relevant sections of the spec, and it seems to me they haven't
been very accurate in a long time. Once server-side scripting and cookies
go added, GET requests are no longer idempotent (i.e. the response from N > 0
of the same requests can and often will be different). There's also no
mention that POST could be idempotent with the stipulation that the same
payload was sent on each of the multiple requests.
That aside, I still come back to the actual behavior of the ServicePoint.
I think I just figured it out going back and forth in the docs.
ServicePoint.ConnectionLimit comes from
ServicePointManager.DefaultConnectionLimit which is 2 unless the app
configures some other value.
What I think is happening is that when my client sends multiple concurrent
requests, the first one goes over the pooled socket. The 2nd one spins up
another socket. The 3rd request hits the ConnectionLimit, so it has to be
queued behind someone.
I'm guessing here but it seems like the 3rd request gets onto a queue tied
to a specific socket, so it can only be sent when the last request completes.
In my case, it ends up getting queued behind socket #1 (which takes 5
seconds to complete) even though socket #2 completes much sooner and could
have been used.
Could you ask if a new request to a ServicePoint after
ServicePoint.ConnectionLimit is reached gets queued with a particular
connection and not the ServicePoint in general?
Thanks
Mark