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 several invocations, the debugger will
actually stop in the catch block.
However, after a number of invocations (variant) the program just hangs on
waiting for the GetResponse(). I would expect the timeout/Webexception to
occur. In monitoring the traffic on the webserver, the requests are coming
in and the server appears to be responding appropriately.
On an additional note, if I comment out the explicit setting of the timeout
to 100 ms (from what I read in the WROX book, default is 100,000 anyway),
then the application never steps into the catch block.
bool sendWebRequest(string URIstring)
{
WebRequest webReq = WebRequest.Create(URIstring);
webReq.Timeout = 100;
try
{
WebResponse webResp = webReq.GetResponse();
return true;
}
catch (WebException e)
{
return false;
}
} 3 2878
Just take away the timeout. I got another sample here: http://msdn2.microsoft.com/en-us/lib...st(d=ide).aspx
chanmm
"Jonathan@IbisTek" <jj****@ibistek.com.(D0N0tSp@m)> wrote in message
news:9F**********************************@microsof t.com... 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 several invocations, the debugger will actually stop in the catch block.
However, after a number of invocations (variant) the program just hangs on waiting for the GetResponse(). I would expect the timeout/Webexception to occur. In monitoring the traffic on the webserver, the requests are coming in and the server appears to be responding appropriately.
On an additional note, if I comment out the explicit setting of the timeout to 100 ms (from what I read in the WROX book, default is 100,000 anyway), then the application never steps into the catch block.
bool sendWebRequest(string URIstring) { WebRequest webReq = WebRequest.Create(URIstring); webReq.Timeout = 100; try { WebResponse webResp = webReq.GetResponse(); return true; } catch (WebException e) { return false; } }
Thanks - but if I actually remove the explicit timeout, it hangs forever.
I played with the numbers and found that 1000000 msec will produce results,
but that is just wayyyy too slow for our purposes. I think I'm going to need
to bypass .NET's web widgets and go the low-level socket route.
Which doesn't make sense, because the response in IE is super fast...?
--
Ibis Tek www.ibistek.com
912 Pittsburgh Road
Butler, PA 16002
"chanmm" wrote: Just take away the timeout. I got another sample here: http://msdn2.microsoft.com/en-us/lib...st(d=ide).aspx
chanmm
"Jonathan@IbisTek" <jj****@ibistek.com.(D0N0tSp@m)> wrote in message news:9F**********************************@microsof t.com...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 several invocations, the debugger will actually stop in the catch block.
However, after a number of invocations (variant) the program just hangs on waiting for the GetResponse(). I would expect the timeout/Webexception to occur. In monitoring the traffic on the webserver, the requests are coming in and the server appears to be responding appropriately.
On an additional note, if I comment out the explicit setting of the timeout to 100 ms (from what I read in the WROX book, default is 100,000 anyway), then the application never steps into the catch block.
bool sendWebRequest(string URIstring) { WebRequest webReq = WebRequest.Create(URIstring); webReq.Timeout = 100; try { WebResponse webResp = webReq.GetResponse(); return true; } catch (WebException e) { return false; } }
Thus wrote jj****@ibistek.com.(D0N0tSp@m), 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 several invocations, the debugger will actually stop in the catch block.
However, after a number of invocations (variant) the program just hangs on waiting for the GetResponse(). I would expect the timeout/Webexception to occur. In monitoring the traffic on the webserver, the requests are coming in and the server appears to be responding appropriately.
On an additional note, if I comment out the explicit setting of the timeout to 100 ms (from what I read in the WROX book, default is 100,000 anyway), then the application never steps into the catch block.
bool sendWebRequest(string URIstring) { WebRequest webReq = WebRequest.Create(URIstring); webReq.Timeout = 100; try { WebResponse webResp = webReq.GetResponse(); return true; } catch (WebException e) { return false; } }
HttpWebResponse is an IDisposable. You have to close it explictly, otherwise
it blocks an underlying TCP connection -- and by default you only get two
persistent connections per server. Use a using block to safely dispose the
response:
using(WebResponse response = request.GetResponse()
{
// Process response...
}
Cheers,
--
Joerg Jooss ne********@joergjooss.de This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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.
|
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()...
|
by: aaronfude |
last post by:
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?
...
|
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...
|
by: SStory |
last post by:
Have noticed that my app sometimes hangs in memory.
It is a multithreaded app with a main thread and a worker thread but I call
something to spin it down on quiting.
Any ideas as to why this...
|
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...
|
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:...
|
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 =...
|
by: Chrace |
last post by:
Hi all,
I have a problem with with Thread.Join( Timeout ) where the timeout never occurs.
I basically need to make a connection to an AS400 box which works fine. Once in a blue moon the AS400...
|
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...
|
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...
|
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...
|
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...
|
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: 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...
|
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...
|
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 ...
| | |