I'm working on a webdav client which makes multiple webrequests using the
threadpool.
The initial issue was that some requests never returned, though I could
attach to the application and see they were still blocked at
webReq.GetRespo nse(). I finally fired up netmon to see where the connection
seemed to be getting lost, and it seems to be a race condition in the TCP
handling. Since I know next to nothing about TCP, or asynchronous
programming hopefully somone else can shed some more light on the issue.
When I see the issue, two threads are sending requests from the same client
port, and one server response overlaps a client ack in transit. This makes
me think that the client views this as having lost a packet and needing to
retransmit. However, the server response which caused the retransmit is
ignored, causing one of the client requests to wait forever for the server to
send a packet which the client has already recieved.
This is a simplified version of the trace data- client sequence numbers are
10+, servers are 110+, they're not continuous since there are other threads
sending data as well.
packet order (client) || Time || Source -Dest || Ack# || Seq# || Request
type || Verb
4 4.633 C -S 100 10 HTTP MKCOL
5 4.828 S -C 20 100 TCP (ack)
6 4.828 C -S 110 20 HTTP PROPPATCH
7 4.929 S -C 30 110 HTTP 201 - created
8 5.112 C -S 120 30 TCP (ack)
9 5.113 S -C 30 120 HTTP 100 - continue
10 5.313 C -S 130 30 TCP (ack)
So packets 8 and 9 are transmitted at the same time, so the client resends
packet 8 as packet 10. However, packet 9 which should trigger the body of
the 'proppatch' request, is never handled by the client.
Anyway- I realize this is long and rambling, so thanks to anyone who read
this far, and double thanks if you have any suggestions either for work
arounds or additional debugging. 2 1936
Hi Jett,
Are you sure that call is not working at all or just really slow?
I've had many issues with the defaut proxy settings which are not using
direct acces but rather try to find the proxy server which fails under
ASP.NET in a typical security environment. THis can be very slow and take up
to 30 seconds+ to resolve for the first call. I suspect this will be true
for any HTTP call on a new thread.
I talked about this here a while back: http://west-wind.com/weblog/posts/3871.aspx
I have a few schedulers as part of my internal WebLog engine that run a fair
number of requests on separate threads and haven't seen any issues with HTTP
trafficking on these outbound calls. It's not super high volume though but
they do run a few threads simultaneously with WebRequest.
Wonder too if you can try using raw threads rather than the threadpool -
maybe that's causing some issues if the threadpool is pressured from request
load... Finally make sure that your code is completely thread safe. Is it
possible your WebRequest instance is getting shared across threads by
accident? This sounds like a possibility given your traffic analyses.
+++ Rick ---
--
Rick Strahl
West Wind Technologies www.west-wind.com/weblog
"Jett Jones" <Jett Jo***@discussio ns.microsoft.co mwrote in message
news:87******** *************** ***********@mic rosoft.com...
I'm working on a webdav client which makes multiple webrequests using the
threadpool.
The initial issue was that some requests never returned, though I could
attach to the application and see they were still blocked at
webReq.GetRespo nse(). I finally fired up netmon to see where the
connection
seemed to be getting lost, and it seems to be a race condition in the TCP
handling. Since I know next to nothing about TCP, or asynchronous
programming hopefully somone else can shed some more light on the issue.
When I see the issue, two threads are sending requests from the same
client
port, and one server response overlaps a client ack in transit. This
makes
me think that the client views this as having lost a packet and needing to
retransmit. However, the server response which caused the retransmit is
ignored, causing one of the client requests to wait forever for the server
to
send a packet which the client has already recieved.
This is a simplified version of the trace data- client sequence numbers
are
10+, servers are 110+, they're not continuous since there are other
threads
sending data as well.
packet order (client) || Time || Source -Dest || Ack# || Seq# || Request
type || Verb
4 4.633 C -S 100 10 HTTP MKCOL
5 4.828 S -C 20 100 TCP (ack)
6 4.828 C -S 110 20 HTTP PROPPATCH
7 4.929 S -C 30 110 HTTP 201 - created
8 5.112 C -S 120 30 TCP (ack)
9 5.113 S -C 30 120 HTTP 100 - continue
10 5.313 C -S 130 30 TCP (ack)
So packets 8 and 9 are transmitted at the same time, so the client resends
packet 8 as packet 10. However, packet 9 which should trigger the body of
the 'proppatch' request, is never handled by the client.
Anyway- I realize this is long and rambling, so thanks to anyone who read
this far, and double thanks if you have any suggestions either for work
arounds or additional debugging.
Thanks for the response rick, though I think I'm not hitting those specific
issues, but let me know if I'm misunderstandin g something. Also I definately
agree that the most likely answer isn't the framework, but I'm also not
finding anything clearly wrong in my code. I'm making all my requests
synchronously, so a request object should never be used outside the thread
which created it. I've left it waiting for responses for more than half an
hour with no success, so I think it's more than the intial proxy setup time.
For my next step I'll try adding additional locks around creating web
requests, on the off chance that that's not synchronized internally.
"Rick Strahl [MVP]" wrote:
Hi Jett,
Are you sure that call is not working at all or just really slow?
I've had many issues with the defaut proxy settings which are not using
direct acces but rather try to find the proxy server which fails under
ASP.NET in a typical security environment. THis can be very slow and take up
to 30 seconds+ to resolve for the first call. I suspect this will be true
for any HTTP call on a new thread.
I talked about this here a while back: http://west-wind.com/weblog/posts/3871.aspx
I have a few schedulers as part of my internal WebLog engine that run a fair
number of requests on separate threads and haven't seen any issues with HTTP
trafficking on these outbound calls. It's not super high volume though but
they do run a few threads simultaneously with WebRequest.
Wonder too if you can try using raw threads rather than the threadpool -
maybe that's causing some issues if the threadpool is pressured from request
load... Finally make sure that your code is completely thread safe. Is it
possible your WebRequest instance is getting shared across threads by
accident? This sounds like a possibility given your traffic analyses.
+++ Rick ---
--
Rick Strahl
West Wind Technologies www.west-wind.com/weblog
"Jett Jones" <Jett Jo***@discussio ns.microsoft.co mwrote in message
news:87******** *************** ***********@mic rosoft.com...
I'm working on a webdav client which makes multiple webrequests using the
threadpool.
The initial issue was that some requests never returned, though I could
attach to the application and see they were still blocked at
webReq.GetRespo nse(). I finally fired up netmon to see where the
connection
seemed to be getting lost, and it seems to be a race condition in the TCP
handling. Since I know next to nothing about TCP, or asynchronous
programming hopefully somone else can shed some more light on the issue.
When I see the issue, two threads are sending requests from the same
client
port, and one server response overlaps a client ack in transit. This
makes
me think that the client views this as having lost a packet and needing to
retransmit. However, the server response which caused the retransmit is
ignored, causing one of the client requests to wait forever for the server
to
send a packet which the client has already recieved.
This is a simplified version of the trace data- client sequence numbers
are
10+, servers are 110+, they're not continuous since there are other
threads
sending data as well.
packet order (client) || Time || Source -Dest || Ack# || Seq# || Request
type || Verb
4 4.633 C -S 100 10 HTTP MKCOL
5 4.828 S -C 20 100 TCP (ack)
6 4.828 C -S 110 20 HTTP PROPPATCH
7 4.929 S -C 30 110 HTTP 201 - created
8 5.112 C -S 120 30 TCP (ack)
9 5.113 S -C 30 120 HTTP 100 - continue
10 5.313 C -S 130 30 TCP (ack)
So packets 8 and 9 are transmitted at the same time, so the client resends
packet 8 as packet 10. However, packet 9 which should trigger the body of
the 'proppatch' request, is never handled by the client.
Anyway- I realize this is long and rambling, so thanks to anyone who read
this far, and double thanks if you have any suggestions either for work
arounds or additional debugging.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 threads from the
ThreadPool. However, eventually (relatively quickly) there become fewer and
fewer available worker threads in the pool, until there are 0 and a
System.InvalidOperationException occurs with the message: "There were not
enough free...
|
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 Cronin
Data On Call - Programmer
|
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 threads from the
ThreadPool. However, eventually (relatively quickly) there become fewer and
fewer available worker threads in the pool, until there are 0 and a
System.InvalidOperationException occurs with the message: "There were not
enough free...
|
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 MSHTML objects to really load the HTML and request all of the images on
site?
string lcUrl = http://www.cnn.com;
// *** Establish the request
|
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." Is there a
way to make sure that the date header is sent over or a way to work around
this exception?
Here's a sample of the code:
| |
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |