Link to home
Start Free TrialLog in
Avatar of mrwarejr
mrwarejrFlag for United States of America

asked on

Help with HttpWebRequest time out

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
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

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

Bob
Avatar of mrwarejr

ASKER

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:
http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest.timeout.aspx
ASKER CERTIFIED SOLUTION
Avatar of ddrudik
ddrudik
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
One more timeout variable to note, when reading/writing to a stream there is another timeout to set:
http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest.readwritetimeout.aspx
Thanks for the question and the points.