0

Im trying to use WebClient.DownloadString() but using proxy. Im doing this:

 WebProxy wp = new WebProxy("http://000.000.000.000:80"); (here goes real proxy ip)
        WebClient wb = new WebClient();
        wb.Proxy = wp;
        try
        {
            string file = wb.DownloadString("http://google.com/");
            System.Console.WriteLine(file);
        }
        catch (Exception e)
        {
            System.Console.WriteLine(e);
        }

And it gives this error when DownloadString is call:

System.Net.WebException: Se ha terminado la conexion: Error inesperado de recepcion. ---> System.IO.IOException: No se puede escribir datos de en la conexion de transporte: Se ha forzado la interrupcion de una conexion existente por el host remoto. ---> System.Net.Sockets.SocketException: Se ha forzado la interrupcion de una conexion existente por el host remoto

If I don't use proxy, it works fine. The proxy also works fine, cause if I configure proxy in Chrome or Firefox, I can access any web page.

Thanks

Richard Brown
  • 11,043
  • 4
  • 31
  • 42
  • Erm...No puedo hablar Español. Could you translate it into Americanese? – Aron Mar 20 '13 at 03:28
  • Would this make a good translation? System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 120.203.215.6:85 – Aron Mar 20 '13 at 03:32
  • Don't forget to remove your IP from your comment. – Prix Mar 20 '13 at 03:34
  • Does your proxy have IP restrictions set up? – rikitikitik Mar 20 '13 at 04:25
  • Translation is something like this: – Maurizio Folcini Mar 20 '13 at 16:41
  • System.Net.WebException: Conection finished: Unespected error in reception. ---> System.IO.IOException:cannt write dataen in transport conection: Forced interruption of existing connection by remote host. ---> System.Net.Sockets.SocketException: Force interruption of existing connection by remote host. I have checked and it seems a proxy problem, im using an internet list of proxys, and if i check, some of them seems to work, and someones not. I really don't understand very well why... – Maurizio Folcini Mar 20 '13 at 16:44

1 Answers1

0

The error that was reported means that there was a RST (reset) packet sent to your computer. It could have been from the proxy or from some firewall that was in the way, but the message No connection could be made because the target machine actively refused it means that something forcibly closed the connection (and in TCP that means a RST packet). My first guess is that the proxy address or port wasn't set correctly.

Zipper
  • 6,684
  • 6
  • 44
  • 64
  • The proxy is correct, but it seems that some proxys doesn't support the request to some webs. They are free public hosts from internet lists. – Maurizio Folcini Mar 20 '13 at 16:45