Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
14.2k views
in Java FTP by (240 points)
We have sucessfully established FTP over SSL connection with the FTPS Server on mainframe after client authentication by using the sample code UseFTPSWithClientServerValidation.java. All the FTP Commands like PWD, CHDIR, DELETE etc are working fine. But when we try to do a get or put we are getting the following:

java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at java.net.SocketInputStream.read(SocketInputStream.java:182)
at java.io.FilterInputStream.read(FilterInputStream.java:66)
at java.io.PushbackInputStream.read(PushbackInputStream.java:120)
at com.enterprisedt.net.puretls.N.A(Unknown Source)
at com.enterprisedt.net.puretls.I.A(Unknown Source)
at com.enterprisedt.net.puretls.Y.A(Unknown Source)
at com.enterprisedt.net.puretls.r.read(Unknown Source)
at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:411)
at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:453)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:183)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at java.io.BufferedReader.fill(BufferedReader.java:136)
at java.io.BufferedReader.readLine(BufferedReader.java:299)
at java.io.BufferedReader.readLine(BufferedReader.java:362)
at com.enterprisedt.net.ftp.FTPControlSocket.D(Unknown Source)
at com.enterprisedt.net.ftp.FTPClient.validateTransfer(Unknown Source)
at com.enterprisedt.net.ftp.FTPClient.B(Unknown Source)
at com.enterprisedt.net.ftp.FTPClient.get(Unknown Source)
at UseFTPSWithClientServerValidation.putGetDelete(UseFTPSWithClientServerValidation.java:149)
at UseFTPSWithClientServerValidation.main(UseFTPSWithClientServerValidation.java:103)

The method where it is failing is pasted below:
private static void putGetDelete(String name, FTPClient ftp)
throws Exception {

try {

System.out.println("LRECL:"+ftp.quote("site LRECL=1000", null));
System.out.println("RECFM:"+ftp.quote("site RECFM=FB", null));
System.out.println("PWD:"+ftp.pwd());
ftp.chdir("..");
ftp.chdir("FTP.BPS");
File objFile = new File("C:/000WORK/0__IT4/NDNH_OUT_FROM_MF.txt");
FileOutputStream objFileOutputStream = new FileOutputStream(objFile);
ftp.get(objFileOutputStream , "'TEST'");
}
catch(java.net.SocketException objExc)
{
objExc.printStackTrace();
}

}

Thanks for your help!

6 Answers

0 votes
by (162k points)
Most likely you are experiencing a firewall problem whereby a data socket being created is blocked by your firewall.

You could try changing from active mode to passive or vice versa, or you may need to talk to your firewall admin - see the developer's manual for a lot more info on FTPS and firewalls.
0 votes
by (240 points)
Thanks Bruce. It was a problem with the firewall. I changed the mode from passive to active and it worked.
0 votes
by (180 points)
Hi everyone,

I have "read timeout" issue that I need help with. I am writing an application that downloads a file from a remote FTP server (in this case vsftpd) and then unzips it locally. I am getting a "Read timed out" error. The output is as follows:

DEBUG [FTPClient] 15 Apr 2007 16:29:34.522 : Class: com.enterprisedt.net.ftp.FTPClient
Version: 1.5.4
Build timestamp: 16-Jan-2007 09:05:59 EST
Java version: 1.5.0_06
CLASSPATH: /home/sshirley/development/Projekte/WuH/KonfexTransport:/home/sshirley/development/libraries/java/edtftpj-1.5.4/edtftpj-1.5.4.jar
OS name: Linux
OS arch: amd64
OS version: 2.6.15-28-amd64-generic

DEBUG [FTPClient] 15 Apr 2007 16:29:34.615 : Connecting to /xx.xx.xx.xx:21
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:34.751 : 220 Welcome to easy-set FTP service.
Connected!
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:34.753 : ---> USER konfexian
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:34.791 : 331 Please specify the password.
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:34.792 : ---> PASS ********
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:34.831 : 230 Login successful.
Logged into the server
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:34.831 : ---> SYST
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:34.870 : 215 UNIX Type: L8
We are connected to: 69.95.35.40 running on UNIX Type: L8 on port: 21
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:34.871 : ---> FEAT
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:34.907 : 211-Features:
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:34.908 : EPRT
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:34.978 : EPSV
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:34.978 : MDTM
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:34.978 : PASV
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:34.978 : REST STREAM
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:34.978 : SIZE
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:34.978 : TVFS
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:34.979 : 211 End
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:34.979 : ---> TYPE I
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:35.18 : 200 Switching to Binary mode.
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:35.18 : ---> CWD updates
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:35.57 : 250 Directory successfully changed.
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:35.57 : ---> PWD
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:35.87 : 257 "/updates"
Currently in dir: /updates
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:35.88 : ---> PASV
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:35.117 : 227 Entering Passive Mode (xx,xx,xx,xx,154,77)
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:35.163 : ---> RETR konfex_20-03-2007.zip
DEBUG [FTPControlSocket] 15 Apr 2007 16:29:35.198 : 150 Opening BINARY mode data connection for konfex_20-03-2007.zip (104930597 bytes).
java.net.SocketTimeoutException: Read timed out
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:411)
at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:453)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:183)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at java.io.BufferedReader.fill(BufferedReader.java:136)
at java.io.BufferedReader.readLine(BufferedReader.java:299)
at java.io.BufferedReader.readLine(BufferedReader.java:362)
at com.enterprisedt.net.ftp.FTPControlSocket.readReply(FTPControlSocket.java:783)
at com.enterprisedt.net.ftp.FTPClient.validateTransfer(FTPClient.java:1503)
at com.enterprisedt.net.ftp.FTPClient.validateTransferOnError(FTPClient.java:1528)
at com.enterprisedt.net.ftp.FTPClient.get(FTPClient.java:1857)
at com.whcorp.sshirley.KonfexTransport.main(KonfexTransport.java:77)

I know from using another FTP program (gFTP) that FTP works from my machine (Ubuntu Linux 6.01 amd64 laptop on a wireless connection). So it has to be something that I am not doing right in my code. As you can see from the features list above, the server doesn't support active mode. I've tried switching to active and doesn't help. Could it have to do with my JVM and ports?

-Sam
0 votes
by (162k points)
Have you tried active mode? Don't rely on FEAT's list.
0 votes
by (180 points)
I have tried it and I get the same error. That was the first thing that I tried. I am not sure if it has to do with the JVM (permissions on accessing ports on the machine). I used gFTP to try to get the file and that used passive mode and was able to get the file. So there is something with my code.
0 votes
by (162k points)
It looks like a firewall problem to me ...

Categories

...