Why does this time out?

  • Thread starter Thread starter Brett
  • Start date Start date
B

Brett

If you paste the URL used in this code into a browser, it will render
without errors. Running the code puts it in the Catch with a Time out error
but not always. I have ran both (see link below also) links through Xenu
with no errors. Any idea why the code produces errors?

Dim statuscode As String
Dim wReq As WebRequest = WebRequest.Create("")
Dim StartTick As Int32

Try
wReq.Timeout = 10000
If TypeOf wReq Is HttpWebRequest Then
CType(wReq, HttpWebRequest).UserAgent = "Mozilla/4.0
(compatible; MSIE 6.0; Windows NT 5.1; Feedreader; .NET CLR 1.1.4322; .NET
CLR 2.0.40607)"
CType(wReq, HttpWebRequest).AllowAutoRedirect = True
End If

StartTick = Environment.TickCount
Dim wResp As HttpWebResponse = DirectCast(wReq.GetResponse(),
HttpWebResponse)
Catch ex As Exception
statuscode = ex.Message()
End Try

This link always gives the error that follows:
http://icerebral.com/dbm83/un.php?1837&19807282
"The underlying connection was closed: the server committed an HTTP protocol
violation."

Thanks,
Brett
 
It looks like the web server hosting the php is issuing an illegal response,
don't know if there's much you can do about that other than handle that
exception, especially if it's intermittent... Does increasing the timeout
have any effect...?
 
Increasing the time out doesn't affect it. Why does it work fine in the
browser?

Thanks,
Brett
 
Back
Top