No Name
No Name

Reputation: 749

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. 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. I'm not sure what permissions are making problems i think i already try everything i can thing of.. Any suggestion...

Upvotes: 1

Views: 2331

Answers (1)

No Name
No Name

Reputation: 749

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. Thanks for the help.

Upvotes: 1

Related Questions