aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes FTP client not working behind 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 client not working behind proxy" Watch "FTP client not working behind proxy" New topic
Author

FTP client not working behind proxy

Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
Hi!

I am using the jakarta net commons library for ftp client. It works fine when I'm not behind a proxy server. I found this information on the net library


Since the Net project uses java.net.Socket under the covers, you have to set
up the Socket settings. If the proxy you are using is a SOCKS4 or SOCKS5
proxy, you can set the following System Properties:

System.getProperties().put( "socksProxyPort", "1080");
System.getProperties().put( "socksProxyHost" ,"proxy.host.address");


When I check the proxy settings for the computer( Mac os x ) we are only using FTP proxy, HTTP proxy and HTTPS proxy. The Socks proxy is not set. How can I still use the jakarta net library? Is there a way to use the ftpProxyPort and ftpProxyHost in the library?

// Mathias


SCJP1.4
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42599
    
  65
Have you tried the other settings mentioned in this discussion?
[ August 15, 2006: Message edited by: Ulf Dittmer ]

Ping & DNS - my free Android networking tools app
Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
Yes! I've tried all of them.

http proxy , ftp proxy and socks proxy.

But our proxy server only has ftp and http. Is there any workaround?
Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
If I use the java.net.Proxy class in java 1.5 then there is no Proxy.Type.FTP. Can I use Proxy.Type.HTTP and connect to an FTP proxy?

If I can't then is there anyway to use the apache commons FTPClient and connect thru a FTP proxy. No HTTP and Socks just FTP?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18882
    
    8

I use Commons FTP Client to connect via an FTP proxy. But the FTP proxy in question is an open-source Java product; I have to connect to it rather than the target FTP server, and pass it the address of the server in a different way than if I were connecting directly. It's not just a matter of changing a system property. However your FTP proxy may work differently.
Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
I don't think setting any of the proxy properties will get me anywere.

I looked into the FTP client class in the jakarta net library and saw that the socket was created from the ServerSocket. Can a proxy be set in the serversocket and/or the socket class without using the java 1.5?

A lot of programmers out there must be in the same situation and solve this. There are not much information when I google around.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18882
    
    8

My proxy server didn't even claim to support FTP, so I got this FTP proxy software and installed it where it could connect to the outside world. Works just fine, except occasionally connections to it hang up. But then that happens for other FTP servers, too. But as I said, you do need to modify the connection code in your software to connect to the proxy instead of the target server.
Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
I have tried connecting thru the java 1.5 Proxy class. Here is my code




I can't create the socket because an IllegalArgumentException is thrown! I don't get it. When i check the settings in the network it only uses Ftp proxy and http proxy no socks proxy.

The ftp proxy port is the same as I use in my java program but I can't connect. How can I connect to a ftp site on port 21 going thru port 1021 on our proxy?
Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
I have still not solved this. All other FTP programs installed on my mac can by typing in the adress and port solv the problem. How come they work and not the jakarta FTP client?
Aalok Pandit
Greenhorn

Joined: Sep 26, 2005
Posts: 15
Hi Mathias

Not sure if this helps you, but I was facing a similar problem.

The error I was getting was :
"Host attempting data connection is not same as server" or something like that.

I have posted the solution in my topic
FTP connection to a Proxy

hope this solves your problem
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FTP client not working behind proxy