【问题标题】:target machine actively refused it error目标机器主动拒绝它错误
【发布时间】:2015-10-20 06:02:13
【问题描述】:

我在下载文件时遇到问题。我正在使用 webclient 下载文件。该代码在本地运行良好,但在 Windows Server 2008 中无法正常运行。我收到错误

[Download File] Error: Download failed: Unable to connect to the remote server
System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 125.7.64.41:8888
   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)

这是我的代码。

string url = "https://test.openseas.wlcl.com.au:8888/cruise/PA/priceSummary?AgentId=DIRECTAU&format=xml";
  WebClient mySSISWebClient = new WebClient();

  mySSISWebClient.Credentials = new NetworkCredential();
  mySSISWebClient.Credentials = new NetworkCredential("username", "password");
  ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
  mySSISWebClient.Encoding = Encoding.Unicode;

  // To save the file (and replace the existing file)
  mySSISWebClient.DownloadFile(url , Dts.Variables["User::LocalSourceFile"].Value.ToString())

请任何人帮助我为什么我在 Windows Server 20087 中遇到此错误,我应该怎么做才能使它工作。谢谢

【问题讨论】:

  • 该错误通常表明没有 Web 服务器在指定的 IP 地址和端口进行侦听,或者 Web 服务器配置为仅接受来自某些计算机的连接。
  • 但这在本地计算机上运行良好,即使我在家也很累,它运行良好,但不是从我上传它的服务器和它的 windows server 2008 @HarryJohnston
  • 如果本地防火墙配置为不允许传出连接,您可能会收到相同的错误消息,我不确定。
  • 是的,我检查了防火墙,它已关闭:/ @HarryJohnston
  • 尝试重新打开它。如果防火墙关闭,网络堆栈有时会在 Windows Server 上做一些有趣的事情。

标签: c# .net ssis c#-3.0 windows-server-2008


【解决方案1】:

您描述的问题听起来像是环境问题,而不是代码相关问题。

我注意到您使用的网址没有有效的 SSL 证书覆盖它。

如果您确定端点是并且永远是安全的,您可以考虑调用如下方法:

System.Net.ServicePointManager.ServerCertificateValidationCallback += ((sender, certificate, chain, sslPolicyErrors) => true);

在您尝试连接之前。请注意,如果您不能完全信任该网站,这是很危险的。通常我只会在你直接拥有服务器的情况下使用它,并将其用于临时测试目的。

另一个潜在问题可能是托管端点的目标计算机上的防火墙配置。

【讨论】:

  • 有人可以帮忙吗?
猜你喜欢
  • 2013-10-21
  • 1970-01-01
  • 2021-05-27
  • 1970-01-01
  • 2011-04-04
  • 1970-01-01
  • 1970-01-01
  • 2013-07-15
  • 2013-05-02
相关资源
最近更新 更多