commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <thorsten.scherler....@juntadeandalucia.es>
Subject Re: Problem proxy with commons-net
Date Tue, 20 Nov 2007 11:00:32 GMT
On Tue, 2007-11-20 at 10:29 +0100, Olivier Filangi wrote:
> Hello,
> 
> I tried to create a connexion on a remote server, 
> I have to use a proxy (squid) to access to the remote server.
> 
> here a simple code:
> 
> System.setProperty("socksProxyHost", ipProxy);
> System.setProperty("socksProxyPort", port);

Try as well:
props.put("java.net.useSystemProxies", true);

> 
> Authenticator.setDefault(new MyAuthenticator());
> FTPClient client = new FTPClient();
> try {
>         System.out.println("connect...");
>         client.connect("ca.expasy.org", 21);
>         System.out.println("login...");
>         client.login("anonymous", "anonymous@nowhere.com");
>         } catch (IOException e) {
>             e.printStackTrace();
>             System.err.println(e.getLocalizedMessage());
>         }
> 
> public class MyAuthenticator extends Authenticator {
>     protected PasswordAuthentication getPasswordAuthentication() {
>         System.out.println("*** getPasswordAuthentication *** ");
>         return new PasswordAuthentication( "login","password" );

Not sure try with:

protected PasswordAuthentication getPasswordAuthentication() {
    return new PasswordAuthentication(user, pass
        .toCharArray());
  }


>     }
> }
> 
> the result is :
> Test:
>      [java] connect...
> 
>      [java] java.net.SocketException: Malformed reply from SOCKS server
>      [java]     at 
> java.net.SocksSocketImpl.readSocksReply(SocksSocketImpl.java:87)
>      [java]     at 
> java.net.SocksSocketImpl.connect(SocksSocketImpl.java:429)
>      [java]     at java.net.Socket.connect(Socket.java:519)
>      [java]     at java.net.Socket.connect(Socket.java:469)
>      [java]     at java.net.Socket.<init>(Socket.java:366)
>      [java]     at java.net.Socket.<init>(Socket.java:180)
>      [java]     at 
> org.apache.commons.net.DefaultSocketFactory.createSocket(DefaultSocketFactory.java:53)
>      [java]     at 
> org.apache.commons.net.SocketClient.connect(SocketClient.java:162)
>      [java]     at Test.main(Test.java:51)
>      [java] Malformed reply from SOCKS server
> 
> 
> I tried to set a lot of system properties 
> (socksProxySet,ftpProxySet,...,socks.proxyHost,....) but nothing works...
> someone have any idea?

HTH

salu2

-- 
Thorsten Scherler                                 thorsten.at.apache.org
Open Source Java                      consulting, training and solutions


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message