HTTPWebRequest GetResponse Timing-out
Could some please tell me why my my code is failing on the GetResponse call?
Dim prxySrver As WebProxy
Dim FileName As String
Dim url As String, respUrl As Uri
Dim gglReq As HttpWebRequest, gglResp As HttpWebResponse, gglStream As Stream
Public Function GoogleSearch() As Boolean
prxySrver = New WebProxy
prxySrver.Address = New Uri("http://proxy.mycompany.com:8080")
prxySrver.Credentials = New NetworkCredential("prxyusr", "prxypswd")
GlobalProxySelection.Select = prxySrver
url = "http://www.google.com/search"
gglReq = CType(WebRequest.Create(url), HttpWebRequest)
gglReq.Proxy = prxySrver
gglReq.KeepAlive = False 'Tried using True and the application hangs up
gglReq.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"
gglReq.Referer = "www.google.com"
gglReq.Timeout = 100
gglReq.AllowAutoRedirect = True
gglReq.MaximumAutomaticRedirections = 10
gglReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 1.0.3705)"
gglReq.ContentType = "application/x-www-form-urlencoded"
gglReq.Method = "POST"
gglReq.Headers.Add("hl", "en")
gglReq.Headers.Add("q", "HTTPWebRequest")
gglReq.Headers.Add("btnG", "Google+Search")
GoogleSearch = True
Try
gglResp = CType(gglReq.GetResponse, HttpWebResponse)
respUrl = gglResp.ResponseUri()
gglStream = gglResp.GetResponseStream()
Catch webEx As WebException 'Message: The operation has timed-out
GoogleSearch = False
Catch prtclEx As ProtocolViolationException
GoogleSearch = False
Catch invOprEx As InvalidOperationException
GoogleSearch = False
End Try
End Function
Thanks
|