I am trying to run this simple code to connect to FTP site through a proxy.

I am getting the following error:
C:\temp\ftp\test>java.exe -cp ./commons-net-ftp-2.0.jar;. MyTest connecting
java.net.SocketException: Malformed reply from SOCKS server
at java.net.SocksSocketImpl.readSocksReply(SocksSocketImpl.java:87)
at java.net.SocksSocketImpl.connectV4(SocksSocketImpl.java:265)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:437)
at java.net.Socket.connect(Socket.java:519)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:176)
at MyTest.main(MyTest.java:23)
loging out
java.lang.NullPointerException
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:471<ftp://FTP.java:471>)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:534<ftp://FTP.java:534>)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:583<ftp://FTP.java:583>)
at org.apache.commons.net.ftp.FTP.quit(FTP.java:794<ftp://FTP.java:794>)
at org.apache.commons.net.ftp.FTPClient.logout(FTPClient.java:697)
at MyTest.main(MyTest.java:39)

I am able to do this using a different FTP client library, ftp4j-1.5.1, using the following code:

So I know the proxy settings are correct.
The java version I used to compile and run my apps is 1.6.0_06 Does anyone can help figure out what is wrong when I use the Apache commons net FTP client?

Thank you

Jon

Post by:Martijn Verburg
, Bartender

Nov 26, 2010 11:41:57

Hi Jon and welcome to Javaranch!

Is that the recommended way to set a proxy using commons-net? Also, download the source code and have a look as to why it could be throwing the NPE at that line. Oh and are you using version 2.0?

Post by:Jon Mena
, Greenhorn

Dec 06, 2010 16:20:57

Based on what I read on the FAQ for the library, this is the way to connect to FTP through proxy. The version is 2.0. I was not able to make it work and used a different library eventually, ftp4j, which worked fine for my need.

Thank you for your reply

Jon

Post by:Karthik Ng
, Greenhorn

Mar 13, 2012 23:38:29

Hi,
I'm facing the same issue( Exception - Malformed reply from SOCKS server), can any one suggest solution?