mrwarejr
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(UR L), HttpWebRequest)
myReq.ContentType = "application/x-www-form-ur lencoded"
myReq.Method = "GET"
myReq.Credentials = CredentialCache.DefaultCre dentials
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(str eam, System.Text.Encoding.ASCII )
Dim strRes As String = streamReader.ReadToEnd
TextBox1.Text = strRes
Dim myReq As HttpWebRequest = CType(WebRequest.Create(UR
myReq.ContentType = "application/x-www-form-ur
myReq.Method = "GET"
myReq.Credentials = CredentialCache.DefaultCre
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(str
Dim strRes As String = streamReader.ReadToEnd
TextBox1.Text = strRes
ASKER
The error I receive is
CreateSO System.Net.WebException: The operation has timed out at System.Net.HttpWebRequest. GetRespons e() at MTODailyOpReports.Form1.Cr eateSO()
It times out after about 2 mins.
CreateSO System.Net.WebException: The operation has timed out at System.Net.HttpWebRequest.
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
http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest.timeout.aspx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest.readwritetimeout.aspx
Thanks for the question and the points.
Bob