我一直在使用许多代理,很少有人可能是错误的/无效的代理,所以超时大多数都不起作用。我不确定dns是否无法解决或者究竟是什么问题。我用过
Dim req As HttpWebRequest = WebRequest.Create(url)
req.Proxy = New WebProxy(proxy)
req.AllowAutoRedirect = False
req.Timeout = 10000
req.ReadWriteTimeout = 10000
Dim res As HttpWebResponse = CType(req.GetResponse(), HttpWebResponse)
Dim stream As Stream = res.GetResponseStream()
Dim streamreader = New StreamReader(stream)
source = streamreader.ReadToEnd()
streamreader.Close()
它对于有效代理很有效,但如果代理已死/无效,则超时不起作用,并且它会一直等待5到10分钟,这是我不想要的。任何形式的帮助都会很棒:)