Solved

Timeout httpwebrequest

Posted on 2008-06-11
1
647 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

739 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