HttpWebRequest problem when running program on server 20033

P

Pål Johansen

I made a program that does screen scraping from a website, but when running
this progran on a Win 2003 server the httpwebrequest works fine for a while
but suddenly never returns from the request (and doesn't time out either)
and I have to restart the program. It works fine on a winxp machine.
**********************************************************
Sub Download_WebPage()
Dim strPost As String
Dim Lines As String
Dim DownloadOk As Boolean
Dim LoggedOn As Boolean
If Mode = "Logon" Then
GetLogonAddress()
LoggedOn = False
End If

strPost = Postdata

Dim myWebResponse As HttpWebResponse
Dim myWebRequest As HttpWebRequest
Dim myWriter As StreamWriter
Dim myReader As StreamReader
Dim PageIdOk As Boolean

Try
myWebRequest = CType(WebRequest.Create(Url), HttpWebRequest)
myWebRequest.CookieContainer = MyCookieContainer

If frm.NUpDownTimeout.Enabled Then myWebRequest.Timeout =
frm.NUpDownTimeout.Value * 1000 'Variable timeoutvalue

If strPost.Length > 0 Then 'If no postdata then don't post
myWebRequest.Method = "POST"
myWebRequest.ContentLength = strPost.Length
myWebRequest.ContentType =
"application/x-www-form-urlencoded"
myWriter = New
StreamWriter(myWebRequest.GetRequestStream())
myWriter.Write(strPost)
myWriter.Close()
End If

myWebResponse = CType(myWebRequest.GetResponse(),
HttpWebResponse)
myReader = New
StreamReader(myWebResponse.GetResponseStream())
Pagedata = myReader.ReadToEnd()
myWebResponse.Close()
LoggedOn = True
CheckPageId(PageId, DownloadOk, LoggedOn) 'Checking pageid
and if we are logged on
Catch e As WebException
DownloadOk = False
LoggedOn = False
Pagedata = FilterErrorMsg(e.ToString)
LogError(Now & "----Post_trade_data:" & Chr(13) & Chr(10) &
e.ToString)
Catch OtherExc As Exception
DownloadOk = False
LoggedOn = False
Pagedata = FilterErrorMsg(OtherExc.ToString)
LogError(Now & "----Post_trade_data:" & Chr(13) & Chr(10) &
OtherExc.ToString)
End Try

myWebResponse = Nothing
myWebRequest = Nothing
myWriter = Nothing
myReader = Nothing

RaiseEvent FinishedWeb(Pagedata, ThreadName, DownloadOk,
LoggedOn)

End Sub
 
C

Cor

Hi Pål
I made a program that does screen scraping from a website, but when running
this progran on a Win 2003 server the httpwebrequest works fine for a while
but suddenly never returns from the request (and doesn't time out either)
and I have to restart the program. It works fine on a winxp machine.

This answer came today in this newsgroup, maybe fits it your problem too.
The sender was Mr. T.
---------------------------------------------------------------------
Info: Problem is solved, John (MSFT) posted this solution which was a 100%
match in another group.

John Soulis wrote:

Please check to see if the article will apply to your issue.
817264 PRB: "Web Access Failed" Error Message When You Use Visual Studio
NET
http://support.microsoft.com/?id=817264

Thank you, John Soulis
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top