简体   繁体   English

.Net Web请求-无法连接到远程服务器

[英].Net Web Request - Unable to connect to the remote server

I'm using .Net Web Request to read the html of selected Webpages. 我正在使用.Net Web请求来读取所选网页的html。

Once in a while I'm getting the following error: 偶尔我会收到以下错误:

2010-09-05 13:14:51,986 [File_29] ERROR Boxer.Classes.GetLinks [(null)] - HtmlUtils - GetResponse - Url - http://domain.com/index.html
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 69.212.110.118:5068
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetResponse()
   at Boxer.Classes.GetLinks.GetResponse(String url, Int32 timeout, Boolean& timeoutException)

I know for sure that the target URL is available. 我肯定知道目标URL可用。

Any idea what is the cause of the error? 知道错误的原因是什么?

There could be different reasons for this happening. 发生这种情况可能有不同的原因。 Maybe the target server is throttling the response because it believes the request comes from a bot. 也许目标服务器正在限制响应,因为它认为请求来自机器人。 In this case you might consider sending proper HTTP headers (if it works in your browser, try sending the same request headers). 在这种情况下,您可以考虑发送适当的HTTP标头(如果它在您的浏览器中有效,请尝试发送相同的请求标头)。 Also there could be a proxy in between that you need to configure and use. 另外,您可能需要在它们之间进行配置和使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM