File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes FTP connection to a Proxy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "FTP connection to a Proxy" Watch "FTP connection to a Proxy" New topic
Author

FTP connection to a Proxy

Aalok Pandit
Greenhorn

Joined: Sep 26, 2005
Posts: 15
Hi
My application requires get, put and rename operations to be performed through Java.

I am using commons-net API by jakarta. The code is able to connect to most of the servers, but in case of a specific proxy server, the connection fails. The IP address of the said server keeps on changing between two values. When the request is routed to one of these IP's the code completes successfully, but fails for the other IP.

Interestingly, if I try FTP through command prompt, or PERL, it always completes. Only Java is not able to connect.

Another thing is that this application also requires SFTP support, so I tried JSch API from JCraft. This also is able to connect to all the servers except the above mentioned proxy server. But in this case, the connection always fails, irrespective of the IP of the proxy.

Please help me out as I've been stuck at this problem for weeks now, also I couldn't find a similar problem anywhere else.
Alfonso Franco
Greenhorn

Joined: Jun 03, 2006
Posts: 20
Hello dear customer software so what do you need get a FTP connection proxy server all at java Ok . I will do, but need to know if you have a FTP specific with Java or I will supply any for you.

Hope reply soon to mail: developfranco@yahoo.com .Thanks Francojava


Alfonso
Aalok Pandit
Greenhorn

Joined: Sep 26, 2005
Posts: 15
I'm sorry franco, but I didn't get what you want to say.
Aalok Pandit
Greenhorn

Joined: Sep 26, 2005
Posts: 15
hey guys

no one ready to help me out!!!
please let me know if a similar issue has already been addressed here. i couldn't find a similar problem anywhere else, that's why i posted it here.
Alfonso Franco
Greenhorn

Joined: Jun 03, 2006
Posts: 20
Hello my friend employer pandit I'am francojava who did recive you e-mail I don't understand what did you say looks check this website called proxy server at http://www.nsftools.com/tips/jProxy.java.Please let's me clear something I'am going to compile this today , but need you full confirmation sorry but It's the key of the problem

My Great Francojava.
developfranco@yahoo.com

Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8900
    
    8

Alfonso must be using a computer translator to go between English and his native tounge. It could use a little work.
Have you tried searching/posting to the Jakarta Commons Mailing List? The crowd over there may be more familiar with the pitfalls of common-net.
You can do basic FTP (i.e. put, get) with URLConnection:

You could also use Runtime.exec() to invoke external ftp/sftp programs.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Alfonso Franco
Greenhorn

Joined: Jun 03, 2006
Posts: 20
Pandit this message is for you I'am alfonso franco who is sending his recent software at http://www.nsftools.com/tips/jProxy.java
Let's clear something I had a mistake writing the website in the first post please here I'am sending the correct website
checkout and tell me after . I still compiling this job yet ?


My Regards Alfonso Franco
Aalok Pandit
Greenhorn

Joined: Sep 26, 2005
Posts: 15
Alfonso : I had a cursory look at the code, and I don't think I can use that code.

Joe : Thanks for the info. I tried to post on the commons community but couldn't find a suitable forum to post it in. I will definitely try using the URL aproach. Can I also perform a directory listing and rename operations from it? It would also be helpful if you could provide some pointers towards achieving secure ftp using a similar approach as my organisation might have some licensing issues if I use third party API's
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8900
    
    8

Are you certain your proxy is configured properly? Are only Java programs getting redirected to this non-functioning ip? Is your server listening on this non-functioning ip?
I know you can do directory listing using the URL approach. I believe you just request a directory rather than a file. I don't know about rename.
As for licensing issues, just look for a library that allows you to redistribute. Drop an email to their sales department and see what their terms are. Remember, your time is worth money too. If you save a week or two by buying something, you are saving your company money.
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
Going through the Commons wiki, I found this Link which addresses your issue.


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Aalok Pandit
Greenhorn

Joined: Sep 26, 2005
Posts: 15
Joe: Thanks for the info. But my organisation wants it to be developed in-house.

Carl: Thanks. Setting up the ftp.proxyHost and ftp.proxyPort properties solved my issue.

Thanks all for your time.
Aalok Pandit
Greenhorn

Joined: Sep 26, 2005
Posts: 15
All

The settings suggested in the link do not help(at least did not help in my case).

How I solved it(Hope it helps someone else):
I looked into the source code of FTPClient and browsed to the code which was throwing the error. There I realised that a verification which generally passes, was failing on the proxy server.

When we instantiate a FTPClient object, a boolean variable remoteVerificationEnabled is set to true by default. This variable is used while doing a connection verification, which fails in case of proxy servers.

So after the instantiation of FTPClient, we need to set the variable to false by calling the setter method.
eg:


Please correct me if I am wrong.
Vinod ..
Greenhorn

Joined: Jan 22, 2009
Posts: 1
hey Aalok..can you please tell me which proxy you were using..??
n aslo which FTP Server..??
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FTP connection to a Proxy