473,387 Members | 1,791 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,387 software developers and data experts.

WebRequest.Timeout has no effect

Hi,

I'm running the following code to read a URL into a string. When the
url is offline, it times out after about 10 seconds regardless of what
I set myRequest.Timeout to.

Any suggestions?

WebRequest myRequest = WebRequest.Create (inURL);
WebResponse myResponse = myRequest.GetResponse();

myRequest.Timeout = 1000;
Stream myStream = myResponse.GetResponseStream ();
StreamReader myReader = new StreamReader (myStream);

string s = myReader.ReadToEnd();

Many thanks in advance.

Aaron Fude

Nov 16 '05 #1
1 4229
aa*******@gmail.com wrote:
Hi,

I'm running the following code to read a URL into a string. When the
url is offline, it times out after about 10 seconds regardless of what
I set myRequest.Timeout to.

Any suggestions?

Let me quote MSDN:

"Timeout is the number of milliseconds that a synchronous request made
with the GetResponse method waits for a response, and the
GetRequestStream methods waits for a stream. [...]"

This doesn't cover any timeout that may occur at lower levels of the
TCP/IP stack -- which is exactly what you have if the remote host is
offline.

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 16 '05 #2

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

Similar topics

5
by: C# Learner | last post by:
Is it possible to create a WebRequest instance and, instead of giving it a URI, give it an actual HTTP request? e.g.: GET / HTTP/1.1 Host: www.google.com CR LF CR LF Thanks in advance.
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()...
9
by: Hasani \(remove nospam from address\) | last post by:
I have a website with 2 aspx pages Foo.aspx, and bar.aspx The content of both files is //in 1 file Hello <%=Session.ToString()%> ================
3
by: Stephane | last post by:
Hi, I'm trying to use PayPal and its Instant Payment Notification. In short, when a payment is made, PayPal send a post to my server and I post it back to PayPal. I'm using WebRequest to do...
0
by: Gordon | last post by:
I use the following code to get source HTML. The second line seems to work when I get no response from a site. However, I want to stop the request if it's taking more than 20 - 30 seconds. I can't...
2
by: LS | last post by:
Hi Guys, I'm building a spider application for our intranet and have problems making webrequests. I spin of 10 threads, they all do the same code, a webrequest and processing of the page. This...
1
by: Christian Urbanczyk | last post by:
Hello! I have a problem with the Webrequest. I've search everywhere to find an answer but it seems that no one has the the problem before. So i hope somebody can help me here! Following Code:...
0
by: thomasabcd | last post by:
Hi, During the user's registration I wan't to geo-code an address using localsearchmaps.com/geo. For that purpose I use a webrequest like this: string url =...
3
by: Jonathan | last post by:
I appreciate anyone's insight on this as I am new to web programming with .NET. I have a simple method which I use to send various HTTP requests to a web server (snippet below). On the first...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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,...

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.