Solved

Timeout httpwebrequest

Posted on 2008-06-11
1
638 Views
Last Modified: 2012-05-11
Hello I am calling a web service with the following code:

1                Dim postData As String
2                Dim encoding As ASCIIEncoding
3                Dim viaRequest As HttpWebRequest = WebRequest.Create("http://72.222.111.00/WebService/WebService.asmx/RequestSnapshot?")
4                postData = "URLRequested=" & URLRequested & "&imageFileName=" & imageFileName & "&CaptureType=Realtime"
5                viaRequest.Method = "POST"
6                viaRequest.ContentType = "application/x-www-form-urlencoded"
7                viaRequest.ContentLength = postData.Length
8                viaRequest.Timeout = "15000"
9    
10               Dim writer As StreamWriter = New StreamWriter(viaRequest.GetRequestStream)
11               writer.Write(postData.ToString)
12               writer.Close()
13  
14               Dim r As HttpWebResponse = viaRequest.GetResponse
15               Dim reader As New StreamReader(r.GetResponseStream)
16               Dim respPage As String = reader.ReadToEnd

 

How can I process some code IF the request takes more than 15 seconds.  I do have a timeout set of 15 seconds but it will not work becuase It will end the request after 15 seconds.  What I would like to accomplish is to process some other code if the request takes longer than 15 seconds but without ending the request to the web service as timeout does.  How can i do this?

 

Thanks Very Much!!
0
Comment
Question by:grogo21
1 Comment
 
LVL 25

Accepted Solution

by:
apeter earned 500 total points
ID: 21762892
May Be you can set the maximum timeout so that your request never fails. In the same method you can have timer function which is trigers after 15 seconds. If you get the response in 15 seconds then you deactivate your timer function.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now