Question : vb.net httpwebrequest timeout not working correctly

Hey,

I created an httpwebrequest and set a timeout for 8000 milliseconds, the only problem is that sometimes it doesn't work correctly and takes 2-10 minutes to load.

Here is my code:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
 Function getUrl(ByVal url)

        log("Getting Url: " & url)

        request = HttpWebRequest.Create(url)
        request.CookieContainer = tempCookies
        request.UserAgent = userAgent
        request.Timeout = 8000

        If useProxy = True Then
            request.Proxy = New WebProxy(ProxyIP)
        End If

        Try
            response = request.GetResponse

            tempCookies.Add(response.Cookies)

            read = New StreamReader(response.GetResponseStream)
            Dim html As String = read.ReadToEnd
            read.Close()

            Return html
        Catch ex As Exception
            log(ex)
            Return False
        End Try

    End Function


Any help would be appreciated, thanks in advance.

Answer : vb.net httpwebrequest timeout not working correctly

Never mind, I solved it.

Had to do:

request.ReadWriteTimeout = 8000
Random Solutions  
 
programming4us programming4us