Solved

Timeout httpwebrequest

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

713 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