简体   繁体   English

在Windows Server 2008上运行Aplication时无法连接到远程服务器

[英]Unable to connect to the remote server when aplication run on windows server 2008

            WebClient zzz = new WebClient();
            WebProxy wp = new WebProxy("62.162.6.11:3128");
            wp.Credentials = CredentialCache.DefaultCredentials;
            zzz.Proxy = wp;

            zzz.Headers.Add("user-agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");
            Byte[] BytesMessage;
            BytesMessage = zzz.DownloadData("http://www.google.com");
            System.Text.UTF8Encoding UTF8 = new System.Text.UTF8Encoding();

            StringMessage = UTF8.GetString(BytesMessage);
            Console.WriteLine(StringMessage);

I have simple code above when running locally everything is OK i can retrieve html code and do staff , but when i compile and place on a server i always receive Unable to connect to remote server error. 当在本地运行时,我上面有简单的代码,一切正常,我可以检索html代码并执行工作人员,但是当我在服务器上进行编译和放置时,我始终会收到无法连接到远程服务器的错误。 Program is started under administrator account, and server browser (IE, FF) can open page that i request in consloe application, also i try to turn off firewall, again same error. 程序以管理员帐户启动,服务器浏览器(IE,FF)可以打开我在consloe应用程序中请求的页面,我也尝试关闭防火墙,再次出现相同的错误。 I'm not sure what permissions are making problems i think i already try everything i can thing of.. Any suggestion... 我不确定什么权限会造成问题,我想我已经尝试了所有可以解决的问题。任何建议...

In this case seems problem is slow/bad internet connection on the server. 在这种情况下,问题似乎是服务器上的互联网连接速度慢/不良。 I just put code in loop if error unable to connect to server occur then run same code again (2 to 5 times), and usually from 2 to 3 times code will connect to server receive data and do the rest of the job. 我只是将代码放入循环中,如果发生无法连接服务器的错误,然后再次运行相同的代码(2至5次),通常2到3次代码将连接到服务器以接收数据并完成其余的工作。 Thanks for the help. 谢谢您的帮助。

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

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