Help with HttpWebRequest time out

mrwarejr used Ask the Experts™
My application is design to open a web page and read the response and display it in a textbox . The page conducts some backend processing which take between 10-15 mins to complete then it is displayed.  The problem is my app times out prior to completion. Opening the page in a browser works just fine. It seems that my app is the one timing out.

            Dim myReq As HttpWebRequest = CType(WebRequest.Create(URL), HttpWebRequest)
            myReq.ContentType = "application/x-www-form-urlencoded"
            myReq.Method = "GET"
            myReq.Credentials = CredentialCache.DefaultCredentials
            Dim myRes As HttpWebResponse = myReq.GetResponse
            myReq.Timeout = "99999999999"
            Dim stream As System.IO.Stream = myRes.GetResponseStream()
            Dim streamReader As System.IO.StreamReader = New System.IO.StreamReader(stream, System.Text.Encoding.ASCII)
            Dim strRes As String = streamReader.ReadToEnd
            TextBox1.Text = strRes
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2008

You are setting the request timeout, so it would be interesting to see where the timeout is occurring.



The error I receive is

CreateSO System.Net.WebException: The operation has timed out at System.Net.HttpWebRequest.GetResponse() at MTODailyOpReports.Form1.CreateSO()

It times out after about 2 mins.
Try specifying the timeout without the value enclosed in quotes, for reference see:
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

Another possible issue is that the timeout is specified after the HttpWebResponse declaration, note the ordering as shown in the reference link above.
One more timeout variable to note, when reading/writing to a stream there is another timeout to set:
Thanks for the question and the points.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial