FULL PRODUCT VERSION :
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux herl26.net4.lan 2.6.9-55.ELsmp #1 SMP Fri Apr 20 16:36:54 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux (on client machine running Java)
EXTRA RELEVANT SYSTEM CONFIGURATION :
Problem has only been reproduced connecting with Solaris FTP servers:
The FTP server packaged with Solaris 9 (Solaris 9 4/04 s9s_u6wos_08a SPARC).
A DESCRIPTION OF THE PROBLEM :
I'm trying to access an FTP server running a Solaris FTP server (see additional config info), and I receive the following exception:
sun.net.ftp.FtpProtocolException: PORT :501 PORT not allowed after EPSV ALL
at sun.net.ftp.FtpClient.openDataConnection(FtpClient.java:435)
at sun.net.ftp.FtpClient.list(FtpClient.java:624)
at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:373)
at java.net.URL.openStream(URL.java:1009)
Looking at the server logs, the problem is that the sun.net.ftp.FtpClient class to access an FTP server, it issues the following commands (some overhead removed):
Sending: TYPE I
200 Type set to I.
Sending: EPSV ALL
200 EPSV ALL command successful.
Sending: EPSV
229 Entering Extended Passive Mode (|||14389|)
Sending: EPRT |1|192.168.2.33|3861|
501 EPRT not allowed after EPSV ALL
Sending: PORT 192,168,2,33,15,21
501 PORT not allowed after EPSV ALL
After sending "EPSV ALL", the client first sends an EPRT command and when the server rejects it, it sends a PORT command.
The server then disconnects the client, making the actual data transfer impossible.
The EPSV ALL command makes the server enter "extended passive mode" which is defined in RFC 2428:
http://tools.ietf.org/html/rfc2428
Section 3 says: "Upon receipt of an EPSV ALL command, the server MUST reject all data connection setup commands other than EPSV (i.e., EPRT, PORT, PASV, et al.)."
It is therefore an error that the client sends the EPRT and PORT commands after EPSV ALL.
The sun.net.ftp.FtpClient class is not invoked directly, it is the default handler for the FTP protocol, called by the java.net.URL class (as can be seen from the stacktrace).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Using the following two lines of Java code, if "myftpserver" runs a Solaris FTP server, will lead to the problem:
URL url = new URL("ftp://myftpserver/");
url.openStream();
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The expected result is that the "steps to reproduce" complete successfully, i.e. the call to openStream() returns an open InputStream to the FTP server and does not throw an exception.
ACTUAL -
On the client:
sun.net.ftp.FtpProtocolException: PORT :501 PORT not allowed after EPSV ALL
at sun.net.ftp.FtpClient.openDataConnection(FtpClient.java:435)
at sun.net.ftp.FtpClient.list(FtpClient.java:624)
at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:373)
at java.net.URL.openStream(URL.java:1009)
Logging the FTP traffic:
Sending: TYPE I
200 Type set to I.
Sending: EPSV ALL
200 EPSV ALL command successful.
Sending: EPSV
229 Entering Extended Passive Mode (|||14389|)
Sending: EPRT |1|192.168.2.33|3861|
501 EPRT not allowed after EPSV ALL
Sending: PORT 192,168,2,33,15,21
501 PORT not allowed after EPSV ALL
ERROR MESSAGES/STACK TRACES THAT OCCUR :
sun.net.ftp.FtpProtocolException: PORT :501 PORT not allowed after EPSV ALL
at sun.net.ftp.FtpClient.openDataConnection(FtpClient.java:435)
at sun.net.ftp.FtpClient.list(FtpClient.java:624)
at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:373)
at java.net.URL.openStream(URL.java:1009)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public static void main(String[] args) {
java.net.URL url = new URL("ftp://myftpserver/");
url.openStream();
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
The only work-around is to use a different FTP server. Most FTP servers are not as critical as the Solaris implementation, and simply ignore the PORT and EPRT commands.
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux herl26.net4.lan 2.6.9-55.ELsmp #1 SMP Fri Apr 20 16:36:54 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux (on client machine running Java)
EXTRA RELEVANT SYSTEM CONFIGURATION :
Problem has only been reproduced connecting with Solaris FTP servers:
The FTP server packaged with Solaris 9 (Solaris 9 4/04 s9s_u6wos_08a SPARC).
A DESCRIPTION OF THE PROBLEM :
I'm trying to access an FTP server running a Solaris FTP server (see additional config info), and I receive the following exception:
sun.net.ftp.FtpProtocolException: PORT :501 PORT not allowed after EPSV ALL
at sun.net.ftp.FtpClient.openDataConnection(FtpClient.java:435)
at sun.net.ftp.FtpClient.list(FtpClient.java:624)
at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:373)
at java.net.URL.openStream(URL.java:1009)
Looking at the server logs, the problem is that the sun.net.ftp.FtpClient class to access an FTP server, it issues the following commands (some overhead removed):
Sending: TYPE I
200 Type set to I.
Sending: EPSV ALL
200 EPSV ALL command successful.
Sending: EPSV
229 Entering Extended Passive Mode (|||14389|)
Sending: EPRT |1|192.168.2.33|3861|
501 EPRT not allowed after EPSV ALL
Sending: PORT 192,168,2,33,15,21
501 PORT not allowed after EPSV ALL
After sending "EPSV ALL", the client first sends an EPRT command and when the server rejects it, it sends a PORT command.
The server then disconnects the client, making the actual data transfer impossible.
The EPSV ALL command makes the server enter "extended passive mode" which is defined in RFC 2428:
http://tools.ietf.org/html/rfc2428
Section 3 says: "Upon receipt of an EPSV ALL command, the server MUST reject all data connection setup commands other than EPSV (i.e., EPRT, PORT, PASV, et al.)."
It is therefore an error that the client sends the EPRT and PORT commands after EPSV ALL.
The sun.net.ftp.FtpClient class is not invoked directly, it is the default handler for the FTP protocol, called by the java.net.URL class (as can be seen from the stacktrace).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Using the following two lines of Java code, if "myftpserver" runs a Solaris FTP server, will lead to the problem:
URL url = new URL("ftp://myftpserver/");
url.openStream();
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The expected result is that the "steps to reproduce" complete successfully, i.e. the call to openStream() returns an open InputStream to the FTP server and does not throw an exception.
ACTUAL -
On the client:
sun.net.ftp.FtpProtocolException: PORT :501 PORT not allowed after EPSV ALL
at sun.net.ftp.FtpClient.openDataConnection(FtpClient.java:435)
at sun.net.ftp.FtpClient.list(FtpClient.java:624)
at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:373)
at java.net.URL.openStream(URL.java:1009)
Logging the FTP traffic:
Sending: TYPE I
200 Type set to I.
Sending: EPSV ALL
200 EPSV ALL command successful.
Sending: EPSV
229 Entering Extended Passive Mode (|||14389|)
Sending: EPRT |1|192.168.2.33|3861|
501 EPRT not allowed after EPSV ALL
Sending: PORT 192,168,2,33,15,21
501 PORT not allowed after EPSV ALL
ERROR MESSAGES/STACK TRACES THAT OCCUR :
sun.net.ftp.FtpProtocolException: PORT :501 PORT not allowed after EPSV ALL
at sun.net.ftp.FtpClient.openDataConnection(FtpClient.java:435)
at sun.net.ftp.FtpClient.list(FtpClient.java:624)
at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:373)
at java.net.URL.openStream(URL.java:1009)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public static void main(String[] args) {
java.net.URL url = new URL("ftp://myftpserver/");
url.openStream();
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
The only work-around is to use a different FTP server. Most FTP servers are not as critical as the Solaris implementation, and simply ignore the PORT and EPRT commands.