Solved

Timeout httpwebrequest

Posted on 2008-06-11
1
641 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 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

10 Experts available now in Live!

Get 1:1 Help Now