Visual basic HttpWebRequest getting SendFailure error

Viewed 55

I have tried many of the recommendations here and am still getting SendFailure error.

Here is the code - it's straight forward web request

Dim request As HttpWebRequest
Dim webAddress As String = "https://www.google.com"
'webAddress = "https://www.yahoo.com"

ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Tls
ServicePointManager.ServerCertificateValidationCallback = _
        New RemoteCertificateValidationCallback(AddressOf AcceptAllCertifications)

request = DirectCast(WebRequest.Create(webAddress), HttpWebRequest)
request.ReadWriteTimeout = 5500
request.Timeout = 5500
request.KeepAlive = False
request.Method = "GET"

Using response = request.GetResponse()
        sr = New StreamReader(response.GetResponseStream())
        activated = sr.ReadToEnd()
        Console.WriteLine("activated says: " + activated)
        resp = Split(activated, ",")
        sr.Close()
        response.Close()
End Using

For the google request, I get the page content in the 'activate' var, and I get a visit hit in the certificate callback function.

For the yahoo request I get an immediate WebException Status 4: SendFailure. There is no hit on the certificate callback function.

Why is this happening? I can not figure it out. I am using VisualStudio 2010.

0 Answers
Related