繁体   English   中英

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

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

我正在使用.Net Web请求来读取所选网页的html。

偶尔我会收到以下错误:

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)

我肯定知道目标URL可用。

知道错误的原因是什么?

发生这种情况可能有不同的原因。 也许目标服务器正在限制响应,因为它认为请求来自机器人。 在这种情况下,您可以考虑发送适当的HTTP标头(如果它在您的浏览器中有效,请尝试发送相同的请求标头)。 另外,您可能需要在它们之间进行配置和使用。

暂无
暂无

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

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