目标机器主动拒绝它错误

时间:2015-10-20 06:02:13

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

我在下载文件时遇到问题。我正在使用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中收到此错误,我应该怎么做才能使它工作。感谢

1 个答案:

答案 0 :(得分:1)

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

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

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

System.Net.ServicePointManager.ServerCertificateValidationCallback += ((sender, certificate, chain, sslPolicyErrors) => true);
在尝试连接之前

。请注意,如果您不能完全信任该网站,这是危险的。通常我只会使用这个是您直接拥有服务器,并将其用于临时测试目的。

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