473,406 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Is there a timeout issue with HttpWebRequest

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
12 17768
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
I'm sending large database files for processing on the database. The
processing can take up to 2 minutes.

Jun 16 '06 #3
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
just TimeOut.
Jun 18 '06 #5
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
>
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
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

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
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
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
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
A read/write. I have not seen any connect timeout
Jun 21 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ram Baruch | last post by:
Hi, I have a question: I made a windows service (using VS wizard). All it does is to connect to my site every X seconds and check if there is anything new to download. If there is- it downloads a...
2
by: news.microsoft.com | last post by:
Hello I try to implement "retry" if connection to web ends with "time out". I want to give a chance to prolong waiting for response. The following code is taken from WebRequest.GetResponse()...
1
by: Jeff B | last post by:
I'm trying to create a simple screen scraping application and I kept getting a System.Net.WebException thrown back with a message of "The operation has timed-out." At first I thought it was some...
2
by: Noggin The Nog | last post by:
Hi all, I've been trying to get HttpWebResponse to work, but whenever I try I get "The operation has timed-out". I'm simply trying to send an HTTP request querystring to a remote website and read...
1
by: davvel | last post by:
It has been 6 days of re-writing the same code in different ways to try and avoid a getResponse Timeout which haunted me for much too long now. I am trying to do a very simple thing which is...
6
by: Russell Stevens | last post by:
I use a WinForm app for users to upload a file to my server. Basically one line of code; Response = WC.UploadData(MyUrl, "PUT", MyByteArray) Works fine except for larger files. After about 104...
2
by: GHS | last post by:
I have some code to connect to a website and pull some content out of the HTML. I've verified that the 2 URLs I'm using are perfectly fine in Internet Explorer and both of them return results...
1
by: stewart.fay | last post by:
Dear all, I am using the HttpWebRequest and HttpWebRequest to send an XML request to an ASPX page. When I use the browser and add my XML request the request is posted fine and an answer is...
0
by: Morgan Cheng | last post by:
In the doc http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest.timeout.aspx, it reads, "A Domain Name System (DNS) query may take up to 15 seconds to return or time out. If your...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.