Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > .NET Web Services
.NET Web Services Discussions about .NET XML Web Service technologies including ASMX files, WSDL and SOAP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Web Services section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 13th, 2005, 11:54 AM
Registered User
Join Date: Jul 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
    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


Similar Threads
Thread Thread Starter Forum Replies Last Post
HTTPWEBRESPONSE and HTTPWEBREQUEST and redirect venkat_NET ASP.NET 2.0 Professional 0 September 15th, 2008 08:20 AM
ProgressBar on httpwebrequest panuvin C# 1 February 5th, 2007 03:24 PM
HttpWebRequest over SSL Suhrit ASP.NET 2.0 Professional 0 December 7th, 2006 03:41 AM
httpWebRequest created differently jlento General .NET 0 November 9th, 2004 05:13 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.