By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,077 Members | 1,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,077 IT Pros & Developers. It's quick & easy.

Is there a timeout issue with HttpWebRequest

P: n/a
I try to set the timeout property on my
HttpWebRequest object before lunching the request.

It seems like any value above 100 seconds is discarded.

Has anyone observered malfunctional with this class?

Thanks
jj
Jun 16 '06 #1
Share this Question
Share on Google+
12 Replies


P: n/a
Hello, Jens!

JJ> It seems like any value above 100 seconds is discarded.

100 seconds is rather big timeout. After 100 seconds TCP connection can timeout, and you will receive
WebException exception.

As a workaround you can try using HttpWebRequest.ServicePoint.MaxIdleTime or if that didn't help
change TCP/IP timeout settings in the OS ( http://support.microsoft.com/kb/314053/ )

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Jun 16 '06 #2

P: n/a
I'm sending large database files for processing on the database. The
processing can take up to 2 minutes.

Jun 16 '06 #3

P: n/a
Thus wrote jens,
I try to set the timeout property on my
HttpWebRequest object before lunching the request.
It seems like any value above 100 seconds is discarded.

Has anyone observered malfunctional with this class?


Are you manipulating Timeout or ReadWriteTimeout?

People quite often use the fomer while actually wanting to use the latter ;-)

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Jun 16 '06 #4

P: n/a
just TimeOut.
Jun 18 '06 #5

P: n/a
Hello, Jens!

JJ> I'm sending large database files for processing on the database. The
JJ> processing can take up to 2 minutes.

Can you provide code sample, where you "send large database files"?
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Jun 19 '06 #6

P: n/a
>
Can you provide code sample, where you "send large database files"?
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com

on the client: ( the xml is stored in "message")

{HttpWebRequest req =
(HttpWebRequest)HttpWebRequest.Create(Configuratio nManager.AppSettings["uri"]);

req.ContentType = "text/xml; charset=utf-8";

req.Method = "POST";

UTF8Encoding encoding = new UTF8Encoding();

byte[] postBytes = encoding.GetBytes(message);

req.ContentLength = postBytes.Length;

System.IO.Stream reqStream = req.GetRequestStream();

reqStream.Write(postBytes, 0, postBytes.Length);

reqStream.Close();

req.Timeout = 1000*int.Parse(
ConfigurationManager.AppSettings["SessionTimeOut"].ToString());
//SessionTimeOut

Log.Write("Sending file:" +
ConfigurationManager.AppSettings[file].ToString());

System.Net.WebResponse resp = (HttpWebResponse)req.GetResponse();
System.IO.StreamReader sr = new
System.IO.StreamReader(resp.GetResponseStream());

message = (sr.ReadToEnd().Trim()).ToString();

Log.Write("Received response of file:" +
ConfigurationManager.AppSettings[file].ToString());
postBytes = encoding.GetBytes(message);

System.IO.File.WriteAllBytes(numb.ToString() + "received.xml", postBytes);

resp.Close();

sr.Close();

On the server:( the server is an xml gateway built as an http handler that
use ODP.NET to intrect with some oracle backend)


public void ProcessRequest (HttpContext context) {

try

{

DataAccess da = new DataAccess();

context.Request.ContentType = "text/xml; charset=utf-8";

System.IO.StreamReader reqStream = new
System.IO.StreamReader(context.Request.InputStream );

irw.message = reqStream.ReadToEnd().Trim();

da.process_message(); // The file is proceesed and the response is stored in
the member "message"

context.Response.ContentType = "text/xml; charset=utf-8";

UTF8Encoding encoding = new UTF8Encoding();

byte[] postBytes = encoding.GetBytes(da.message);

context.Response.OutputStream.Write(postBytes, 0, postBytes.Length);

}

catch(Exception exe)

{

Log.Write(exe);

}


}

Thanks

JJ
Jun 20 '06 #7

P: n/a
Hello, Jens!

Did you try, using HttpWebRequest.ReadWriteTimeout on both sides?

Do you receive timeout exception?

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Jun 20 '06 #8

P: n/a

On the server side, the default timeout is 30 minute what should be largely
enough . Should i be using ReadWriteTimeout instead of jus Timeout?

Thanks
JJ
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com

Jun 20 '06 #9

P: n/a
You probably just want to use the Timeout property:

Timeout is the number of milliseconds that a subsequent synchronous request
made with the GetResponse method waits for a response, and the
GetRequestStream method waits for a stream. If the resource is not returned
within the time-out period, the request throws a WebException with the Status
property set to WebExceptionStatus.Timeout.

Timeout does not work if you are making asynchronous calls, in that case you
need to implement your own timeout mechanism.

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Jens Jensen" wrote:

On the server side, the default timeout is 30 minute what should be largely
enough . Should i be using ReadWriteTimeout instead of jus Timeout?

Thanks
JJ
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com


Jun 20 '06 #10

P: n/a
So how to explain the misterious timeout i experience using this class?
I set the timeout value to 100 000 milliseconds, and i do observe a timeout
exeption in about 90 seconds.

Has anyone seen anything similart before?
Jun 20 '06 #11

P: n/a
Thus wrote jens,
So how to explain the misterious timeout i experience using this
class?

I set the timeout value to 100 000 milliseconds, and i do observe a
timeout exeption in about 90 seconds.

Has anyone seen anything similart before?


Regarding my previous reply: Do you know whether this is a connect or a read/write
timeout?

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Jun 21 '06 #12

P: n/a
A read/write. I have not seen any connect timeout
Jun 21 '06 #13

This discussion thread is closed

Replies have been disabled for this discussion.