HttpWebRequest timeouts?

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

I create a HttpWebRequest as follows:

m_req = (HttpWebRequest) WebRequest.Create(url);
m_req.Timeout = 10000*1000;
m_req.Method = "POST";
// issue request

I issue my request and receive the HTTP headers. However as the
request is a long running dynamic request for computed data the body
will not be sent for some time. What happens to me is that the request
times out on the Read long before my 10000 secs is up (typically
500-1000 secs)!
I can see no other timeout to set to prevent this happening - is there
any other
workaround?

HttpWebResponse res = (HttpWebResponse) m_req.GetResponse();
// I can see res.Headers
// Read on res.GetResponseStream() times out

The reason that the server sends the HTTP headers before the body is
because the requests are dynamic it can NOT predict the size of the
response document and therefore just produces it as it process the
request (e.g. a large database query of indeterminate response size).

My basic question is the HTTP timeout being propagated to the lowlevel
Read method calls!?

I have used the following code to read the message in a chunked
fashion and this still times out prematurely with the stack trace:

System.Net.WebException: The operation has timed-out.
at System.Net.ConnectStream.Read(Byte[] buffer, Int32 offset, Int32
size)
at System.IO.StreamReader.ReadBuffer(Char[] userBuffer, Int32
userOffset, Int32 desiredChars, Boolean& readToUserBuffer)
at System.IO.StreamReader.Read(Char[] buffer, Int32 index, Int32
count)
at ...

Many thanks in advance for any useful answers!
 
OK.

I was hoping for a .NET 1.1 Service Pack but there has not been one.

The evidence I have is that if I use TcpClient to do the long running
HTTP request then I send the request and receive the response. At one
point in the chunked transfer there is a wait of 20-25 minutes for one
of the chunks (i.e. significant server processing).

It looks to me like there is a fault in the .NET HttpWebRequest
implementation that fails to pass on any significant timeouts down to
the communications layer - i.e. the raw reads.
 
Back
Top