Cannot connect socket through socks proxy

B

Barney

Hi,

I'm having problems using the Apache Commons FTPClient to connect to an
external FTP site through a firewall:

System.setProperty("socksProxyHost", proxyUrl);
System.setProperty("socksProxyPort", proxyPort);

FTPClient ftp = new FTPClient();
try {
ftp.connect(url);
...

When I run this, the whole thing just hangs. However, using a
standalong FTP client (SmartFTP) configured with the same settings
works fine.

Using Ethereal, I had a look at the network traffic. The SmartFTP
session connects directly using SOCKS4, whereas the java session first
tries SOCKS5 and then falls back to SOCKS4. This all looks fine. This
level of detail is all getting a bit beyond me, but the problem appears
to be in the SOCKS connection packet being sent.

Successful connection:

Frame 4 (63 bytes on wire, 63 bytes captured)
Ethernet II, Src: 00:0d:56:c5:6c:27, Dst: 00:00:5e:00:01:02
Internet Protocol, Src Addr: <local.ip.address>, Dst Addr:
<proxy.ip.address>
Transmission Control Protocol, Src Port: 4313 (4313), Dst Port: 1080
(1080), Seq: 1, Ack: 1, Len: 9
Socks Protocol
Version: 4
Command: 1 (Connect)
Remote Port: 21
Remote Address: <external.ftp.server>
User Name:

Unsuccessful connection:

Frame 4 (55 bytes on wire, 55 bytes captured)
Ethernet II, Src: 00:0d:56:c5:6c:27, Dst: 00:00:5e:00:01:02
Internet Protocol, <local.ip.address>, Dst Addr: <proxy.ip.address>
Transmission Control Protocol, Src Port: 4600 (4600), Dst Port: 1080
(1080), Seq: 1, Ack: 1, Len: 1
Socks Protocol
Version: 5
[Unreassembled Packet (incorrect TCP checksum): Socks]

Of course, this could all just be an Ethereal problem.

Either way, does anyone have any idea what is going wrong here, and how
I can fix it?

Running on Windows XP Pro
java version "1.4.2_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)
Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)

Thanks,

Barney
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,835
Latest member
KetoRushACVBuy

Latest Threads

Top