Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
14.1k views
in Java FTP by (480 points)
Hi,
I am using Edit FTP pro to connect to a vendor FTP site using Implicit FTPS. I am trying to put a file. I have verified that the file is getting to it's destination correctly, but I am getting the following error on the FTP client site

java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.read(SocketInputStream.java:140)
at java.net.SocketInputStream.read(SocketInputStream.java:193)
at java.io.FilterInputStream.read(FilterInputStream.java:77)
at java.io.PushbackInputStream.read(PushbackInputStream.java:133)
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:452)
at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:494)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:222)
at java.io.InputStreamReader.read(InputStreamReader.java:177)
at java.io.BufferedReader.fill(BufferedReader.java:147)
at java.io.BufferedReader.readLine(BufferedReader.java:310)
at java.io.BufferedReader.readLine(BufferedReader.java:373)
at com.enterprisedt.net.ftp.FTPControlSocket.E(Unknown Source)
at com.enterprisedt.net.ftp.FTPClient.validateTransfer(Unknown Source)
at com.enterprisedt.net.ftp.FTPClient.put(Unknown Source)
at com.enterprisedt.net.ftp.FTPClient.put(Unknown Source)
at com.enterprisedt.net.ftp.FTPClient.put(Unknown Source)
..................................................

After having gone through your forums I came across the SSLFTPClient.ConfigFlags.DISABLE_SSL_CLOSURE flag.
I have used that flag as suggested, but I was still getting same exception. So, I increased the timeout value as follows, to see if timeout is an issue.
ftp.setTimeout( 180000 );

Now I am getting the following exception.

com.enterprisedt.net.puretls.SSLPrematureCloseException: Short read
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:452)
at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:494)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:222)
at java.io.InputStreamReader.read(InputStreamReader.java:177)
at java.io.BufferedReader.fill(BufferedReader.java:147)
at java.io.BufferedReader.readLine(BufferedReader.java:310)
at java.io.BufferedReader.readLine(BufferedReader.java:373)
at com.enterprisedt.net.ftp.FTPControlSocket.E(Unknown Source)
at com.enterprisedt.net.ftp.FTPControlSocket.B(Unknown Source)
at com.enterprisedt.net.ftp.FTPControlSocket.<init>(Unknown Source)
at com.enterprisedt.net.ftp.ssl.SSLFTPControlSocket.<init>(Unknown Source)
at com.enterprisedt.net.ftp.ssl.SSLFTPClient.connect(Unknown Source)
...........................................

I really like Edit FTP pro for it's simplicity, documentation and that it is java based. So, I started using it. But we are very close to moving this into production and I really need some help with this or I may be forced to move on to a different FTP program.

Please let me know if you need any more logging informaiton and I will send it right away?

Thanks
Sowjanya

17 Answers

0 votes
by (161k points)
First thing is confirm that you can transfer using Filezilla. You could have a firewall problem.
0 votes
by (480 points)
I checked with our firewall administrator and all ports i.e. 990,991 and 992(telnet) ports are open.
I am not able to list the file on the FTP server using File Zilla but here is what I see when I tried to send the same file over using Filezilla

I have the FTP Server and ID XXed out.

Status: Resolving address of xxxxxx.xxxxxxxxxx.com
Status: Connecting to 65.164.177.134:990...
Status: Connection established, initializing TLS...
Status: Verifying certificate...
Status: TLS/SSL connection established, waiting for welcome message...
Response: 220-TCP/IP for VSE Internal FTPDAEMN 01.05 F 20090205 02.33
Response: Copyright (c) 1995,2006 Connectivity Systems Incorporated
Response: 220 Ready for new user
Command: USER XXXX
Response: 331 User name okay, need password
Command: PASS *******
Response: 230 User logged in, proceed
Command: SYST
Response: 215 UNIX Simulation on VSE system
Command: FEAT
Response: 211-Extensions supported:
Response: AUTH TLS
Response: PBSZ
Response: PROT
Response: EPSV
Response: 211 End
Command: PBSZ 0
Response: 200 Protection buffer size accepted.
Command: PROT P
Response: 200 Data connection set to private.
Status: Connected
Status: Retrieving directory listing...
Command: PWD
Response: 257 "/"
Command: TYPE I
Response: 200 Command okay
Command: PASV
Response: 227 Entering Passive Mode (65,164,177,134,3,223)
Command: LIST
Response: 150 File status okay; about to open data connection
Response: 150 Opening secure data connection.
Error: Failed to retrieve directory listing
Status: Disconnected from server
20:19:37 Status: Resolving address of xxxxxx.xxxxxxxxxx.com
20:19:37 Status: Connecting to 65.164.177.134:990...
20:19:37 Status: Connection established, initializing TLS...
20:19:37 Trace: CTlsSocket::Handshake()
20:19:37 Trace: CTlsSocket::ContinueHandshake()
20:19:37 Trace: CTlsSocket::OnSend()
20:19:37 Trace: CTlsSocket::OnRead()
20:19:37 Trace: CTlsSocket::ContinueHandshake()
20:19:37 Trace: CTlsSocket::OnRead()
20:19:37 Trace: CTlsSocket::ContinueHandshake()
20:19:37 Trace: CTlsSocket::OnRead()
20:19:37 Trace: CTlsSocket::ContinueHandshake()
20:19:37 Trace: Handshake successful
20:19:37 Trace: Cipher: AES-256-CBC, MAC: SHA1
20:19:37 Status: Verifying certificate...
20:19:37 Trace: CFtpControlSocket::SendNextCommand()
20:19:37 Status: TLS/SSL connection established, waiting for welcome message...
20:19:37 Trace: CFtpControlSocket::OnReceive()
20:19:37 Response: 220-TCP/IP for VSE Internal FTPDAEMN 01.05 F 20090205 02.33
20:19:37 Trace: CTlsSocket::OnRead()
20:19:37 Trace: CFtpControlSocket::OnReceive()
20:19:37 Response: Copyright (c) 1995,2006 Connectivity Systems Incorporated
20:19:37 Trace: CTlsSocket::OnRead()
20:19:37 Trace: CFtpControlSocket::OnReceive()
20:19:37 Response: 220 Ready for new user
20:19:37 Trace: CFtpControlSocket::SendNextCommand()
20:19:37 Command: USER XXXX
20:19:37 Trace: CTlsSocket::OnRead()
20:19:37 Trace: CFtpControlSocket::OnReceive()
20:19:37 Response: 331 User name okay, need password
20:19:37 Trace: CFtpControlSocket::SendNextCommand()
20:19:37 Command: PASS *******
20:19:37 Trace: CTlsSocket::OnRead()
20:19:37 Trace: CFtpControlSocket::OnReceive()
20:19:37 Response: 230 User logged in, proceed
20:19:37 Trace: CFtpControlSocket::SendNextCommand()
20:19:37 Command: PBSZ 0
20:19:37 Trace: CTlsSocket::OnRead()
20:19:37 Trace: CFtpControlSocket::OnReceive()
20:19:37 Response: 200 Protection buffer size accepted.
20:19:37 Trace: CFtpControlSocket::SendNextCommand()
20:19:37 Command: PROT P
20:19:37 Trace: CTlsSocket::OnRead()
20:19:37 Trace: CFtpControlSocket::OnReceive()
20:19:37 Response: 200 Data connection set to private.
20:19:37 Status: Connected
20:19:37 Trace: CFtpControlSocket::ResetOperation(0)
20:19:37 Trace: CControlSocket::ResetOperation(0)
20:19:37 Trace: CFileZillaEnginePrivate::ResetOperation(0)
20:19:37 Status: Retrieving directory listing...
20:19:37 Trace: CFtpControlSocket::SendNextCommand()
20:19:37 Trace: CFtpControlSocket::ChangeDirSend()
20:19:37 Command: PWD
20:19:37 Trace: CTlsSocket::OnRead()
20:19:37 Trace: CFtpControlSocket::OnReceive()
20:19:37 Response: 257 "/"
20:19:37 Trace: CFtpControlSocket::ResetOperation(0)
20:19:37 Trace: CControlSocket::ResetOperation(0)
20:19:37 Trace: CFtpControlSocket::ParseSubcommandResult(0)
20:19:37 Trace: CFtpControlSocket::ListSubcommandResult()
20:19:37 Trace: state = 1
20:19:37 Trace: CFtpControlSocket::SendNextCommand()
20:19:37 Trace: CFtpControlSocket::TransferSend()
20:19:37 Trace: state = 1
20:19:37 Command: TYPE I
20:19:37 Trace: CTlsSocket::OnRead()
20:19:37 Trace: CFtpControlSocket::OnReceive()
20:19:37 Response: 200 Command okay
20:19:37 Trace: CFtpControlSocket::TransferParseResponse()
20:19:37 Trace: code = 2
20:19:37 Trace: state = 1
20:19:37 Trace: CFtpControlSocket::SendNextCommand()
20:19:37 Trace: CFtpControlSocket::TransferSend()
20:19:37 Trace: state = 2
20:19:37 Command: PASV
20:19:37 Trace: CTlsSocket::OnRead()
20:19:37 Trace: CFtpControlSocket::OnReceive()
20:19:37 Response: 227 Entering Passive Mode (65,164,177,134,3,223)
20:19:37 Trace: CFtpControlSocket::TransferParseResponse()
20:19:37 Trace: code = 2
20:19:37 Trace: state = 2
20:19:37 Trace: CFtpControlSocket::SendNextCommand()
20:19:37 Trace: CFtpControlSocket::TransferSend()
20:19:37 Trace: state = 4
20:19:37 Command: LIST
20:19:37 Trace: CTransferSocket::OnConnect
20:19:37 Trace: CTlsSocket::Handshake()
20:19:37 Trace: CTlsSocket::ContinueHandshake()
20:19:37 Trace: CTlsSocket::OnSend()
20:19:37 Trace: CTlsSocket::OnSend()
20:19:37 Trace: CTlsSocket::OnRead()
20:19:37 Trace: CTlsSocket::ContinueHandshake()
20:19:37 Trace: CTlsSocket::OnRead()
20:19:37 Trace: CFtpControlSocket::OnReceive()
20:19:37 Response: 150 File status okay; about to open data connection
20:19:37 Trace: CFtpControlSocket::TransferParseResponse()
20:19:37 Trace: code = 1
20:19:37 Trace: state = 4
20:19:37 Trace: CFtpControlSocket::SendNextCommand()
20:19:37 Trace: CFtpControlSocket::TransferSend()
20:19:37 Trace: state = 5
20:19:37 Trace: CTlsSocket::OnRead()
20:19:37 Trace: CFtpControlSocket::OnReceive()
20:19:37 Response: 150 Opening secure data connection.
20:19:37 Trace: CFtpControlSocket::TransferParseResponse()
20:19:37 Trace: code = 1
20:19:37 Trace: state = 5
20:19:37 Trace: CFtpControlSocket::ResetOperation(2)
20:19:37 Trace: CControlSocket::ResetOperation(2)
20:19:37 Trace: CFtpControlSocket::ParseSubcommandResult(2)
20:19:37 Trace: CFtpControlSocket::ListSubcommandResult()
20:19:37 Trace: state = 3
20:19:37 Trace: CFtpControlSocket::ResetOperation(2)
20:19:37 Trace: CControlSocket::ResetOperation(2)
20:19:37 Error: Failed to retrieve directory listing
20:19:37 Trace: CFileZillaEnginePrivate::ResetOperation(2)
20:20:16 Status: Resolving address of xxxxxx.xxxxxxxxxx.com
20:20:16 Status: Connecting to 65.164.177.134:990...
20:20:16 Status: Connection established, initializing TLS...
20:20:16 Trace: CTlsSocket::Handshake()
20:20:16 Trace: CTlsSocket:
0 votes
by (161k points)
It's not port 990 that is the problem. A firewall is preventing connection from your client to the server on the data port, which is specified in the PASV command and completely different to port 990. Before talking to your administrator, you should probably try active mode transfers - try Filezilla first.
0 votes
by (480 points)
Realy appreciate the quick response.
I see the following line fileZilla log referring to port command and passive mode.

22:02:28 Response: 502 PORT command not allowed. Use passive mode.

What does that mean?

When I tried to put the file in active mode with FileZilla, I got the following response.


22:01:48 Status: Resolving address of xxxxxx.xxxxxxxxxx.com
22:01:48 Status: Connecting to 65.164.177.134:990...
22:01:49 Status: Connection established, initializing TLS...
22:01:49 Trace: CTlsSocket::Handshake()
22:01:49 Trace: CTlsSocket::ContinueHandshake()
22:01:49 Trace: CTlsSocket::OnSend()
22:01:49 Trace: CTlsSocket::OnRead()
22:01:49 Trace: CTlsSocket::ContinueHandshake()
22:01:49 Trace: CTlsSocket::OnRead()
22:01:49 Trace: CTlsSocket::ContinueHandshake()
22:01:49 Trace: CTlsSocket::OnRead()
22:01:49 Trace: CTlsSocket::ContinueHandshake()
22:01:49 Trace: Handshake successful
22:01:49 Trace: Cipher: AES-256-CBC, MAC: SHA1
22:01:49 Status: Verifying certificate...
22:02:27 Trace: CFtpControlSocket::SendNextCommand()
22:02:27 Status: TLS/SSL connection established, waiting for welcome message...
22:02:27 Trace: CFtpControlSocket::OnReceive()
22:02:27 Response: 220-TCP/IP for VSE Internal FTPDAEMN 01.05 F 20090205 02.33
22:02:27 Response: Copyright (c) 1995,2006 Connectivity Systems Incorporated
22:02:27 Response: 220 Ready for new user
22:02:27 Trace: CFtpControlSocket::SendNextCommand()
22:02:27 Command: USER XXXX
22:02:27 Trace: CTlsSocket::OnRead()
22:02:27 Trace: CFtpControlSocket::OnReceive()
22:02:27 Response: 331 User name okay, need password
22:02:27 Trace: CFtpControlSocket::SendNextCommand()
22:02:27 Command: PASS *******
22:02:27 Trace: CTlsSocket::OnRead()
22:02:27 Trace: CFtpControlSocket::OnReceive()
22:02:27 Response: 230 User logged in, proceed
22:02:27 Trace: CFtpControlSocket::SendNextCommand()
22:02:27 Command: SYST
22:02:27 Trace: CTlsSocket::OnRead()
22:02:27 Trace: CFtpControlSocket::OnReceive()
22:02:27 Response: 215 UNIX Simulation on VSE system
22:02:27 Trace: CFtpControlSocket::SendNextCommand()
22:02:27 Command: FEAT
22:02:28 Trace: CTlsSocket::OnRead()
22:02:28 Trace: CFtpControlSocket::OnReceive()
22:02:28 Response: 211-Extensions supported:
22:02:28 Response: AUTH TLS
22:02:28 Response: PBSZ
22:02:28 Response: PROT
22:02:28 Response: EPSV
22:02:28 Response: 211 End
22:02:28 Trace: CFtpControlSocket::SendNextCommand()
22:02:28 Command: PBSZ 0
22:02:28 Trace: CTlsSocket::OnRead()
22:02:28 Trace: CFtpControlSocket::OnReceive()
22:02:28 Response: 200 Protection buffer size accepted.
22:02:28 Trace: CFtpControlSocket::SendNextCommand()
22:02:28 Command: PROT P
22:02:28 Trace: CTlsSocket::OnRead()
22:02:28 Trace: CFtpControlSocket::OnReceive()
22:02:28 Response: 200 Data connection set to private.
22:02:28 Status: Connected
22:02:28 Trace: CFtpControlSocket::ResetOperation(0)
22:02:28 Trace: CControlSocket::ResetOperation(0)
22:02:28 Trace: CFileZillaEnginePrivate::ResetOperation(0)
22:02:28 Status: Retrieving directory listing...
22:02:28 Trace: CFtpControlSocket::SendNextCommand()
22:02:28 Trace: CFtpControlSocket::ChangeDirSend()
22:02:28 Command: PWD
22:02:28 Trace: CTlsSocket::OnRead()
22:02:28 Trace: CFtpControlSocket::OnReceive()
22:02:28 Response: 257 "/"
22:02:28 Trace: CFtpControlSocket::ResetOperation(0)
22:02:28 Trace: CControlSocket::ResetOperation(0)
22:02:28 Trace: CFtpControlSocket::ParseSubcommandResult(0)
22:02:28 Trace: CFtpControlSocket::ListSubcommandResult()
22:02:28 Trace: state = 1
22:02:28 Trace: CFtpControlSocket::SendNextCommand()
22:02:28 Trace: CFtpControlSocket::TransferSend()
22:02:28 Trace: state = 1
22:02:28 Command: TYPE I
22:02:28 Trace: CTlsSocket::OnRead()
22:02:28 Trace: CFtpControlSocket::OnReceive()
22:02:28 Response: 200 Command okay
22:02:28 Trace: CFtpControlSocket::TransferParseResponse()
22:02:28 Trace: code = 2
22:02:28 Trace: state = 1
22:02:28 Trace: CFtpControlSocket::SendNextCommand()
22:02:28 Trace: CFtpControlSocket::TransferSend()
22:02:28 Trace: state = 2
22:02:28 Command: PORT 157,250,86,7,4,167
22:02:28 Trace: CTlsSocket::OnRead()
22:02:28 Trace: CFtpControlSocket::OnReceive()
22:02:28 Response: 502 PORT command not allowed. Use passive mode.
22:02:28 Trace: CFtpControlSocket::TransferParseResponse()
22:02:28 Trace: code = 5
22:02:28 Trace: state = 2
22:02:28 Trace: CFtpControlSocket::SendNextCommand()
22:02:28 Trace: CFtpControlSocket::TransferSend()
22:02:28 Trace: state = 2
22:02:28 Command: PASV
22:02:29 Trace: CTlsSocket::OnRead()
22:02:29 Trace: CFtpControlSocket::OnReceive()
22:02:29 Response: 227 Entering Passive Mode (65,164,177,134,3,223)
22:02:29 Trace: CFtpControlSocket::TransferParseResponse()
22:02:29 Trace: code = 2
22:02:29 Trace: state = 2
22:02:29 Trace: CFtpControlSocket::SendNextCommand()
22:02:29 Trace: CFtpControlSocket::TransferSend()
22:02:29 Trace: state = 4
22:02:29 Command: LIST
22:02:29 Trace: CTransferSocket::OnConnect
22:02:29 Trace: CTlsSocket::Handshake()
22:02:29 Trace: CTlsSocket::ContinueHandshake()
22:02:29 Trace: CTlsSocket::OnSend()
22:02:29 Trace: CTlsSocket::OnRead()
22:02:29 Trace: CTlsSocket::OnSend()
22:02:29 Trace: CTlsSocket::OnRead()
22:02:29 Trace: CTlsSocket::ContinueHandshake()
22:02:29 Trace: CFtpControlSocket::OnReceive()
22:02:29 Response: 150 File status okay; about to open data connection
22:02:29 Trace: CFtpControlSocket::TransferParseResponse()
22:02:29 Trace: code = 1
22:02:29 Trace: state = 4
22:02:29 Trace: CFtpControlSocket::SendNextCommand()
22:02:29 Trace: CFtpControlSocket::TransferSend()
22:02:29 Trace: state = 5
22:02:29 Trace: CTlsSocket::OnRead()
22:02:29 Trace: CFtpControlSocket::OnReceive()
22:02:29 Response: 150 Opening secure data connection.
22:02:29 Trace: CFtpControlSocket::TransferParseResponse()
22:02:29 Trace: code = 1
22:02:29 Trace: state = 5
22:02:29 Trace: CFtpControlSocket::ResetOperation(2)
22:02:29 Trace: CControlSocket::ResetOperation(2)
22:02:29 Trace: CFtpControlSocket::ParseSubcommandResult(2)
22:02:29 Trace: CFtpControlSocket::ListSubcommandResult()
22:02:29 Trace: state = 3
22:02:29 Trace: CFtpControlSocket::ResetOperation(2)
22:02:29 Trace: CControlSocket::ResetOperation(2)
22:02:29 Error: Failed to retrieve directory listing
22:02:29 Trace: CFileZillaEnginePrivate::ResetOperation(2)
22:03:17 Status: Resolving address of xxxxxx.xxxxxxxxxx.com
22:03:17 Status: Connecting to 65.164.177.134:990...
22:03:17 Status: Connection established, initializing TLS...
22:03:17 Trace: CTlsSocket::Handshake()
22:03:17 Trace: CTlsSocket::ContinueHandshake()
22:03:17 Trace: CTlsSocket::OnSend()
22:03:17 Trace: CTlsSocket::OnRead()
22:03:17 Trace: CTlsSocket::ContinueHandshake()
22:03:18 Trace: CTlsSocket::OnRead()
22:03:18 Trace: CTlsSocket::ContinueHandshake()
22:03:18 Trace: CTlsSocket::OnRead()
22:03:18 Trace: CTlsSocket::ContinueHandshake()
22:03:18 Trace: Handshake successful
22:03:18 Trace: Cipher: AES-256-CBC, MAC: SHA1
22:03:18 Status: Verifying certificate...
22:03:18 Tr
0 votes
by (161k points)
It means active mode is disallowed on the server. You'll have to use passive mode. Which means you need to know the passive port range of the server - this is the range of ports that the server will be using for data connections from the client. You'll then need to permission your firewall to allow the client to use these ports (outgoing to the server).
0 votes
by (480 points)
I see the following line when I attempted to transfer in passive mode.

227 Entering Passive Mode (65,164,177,134,3,223)

I came across the following equation on some other website
.....................
227 Entering Passive Mode (a1,a2,a3,a4,p1,p2)
where a1.a2.a3.a4 is the IP address and p1*256+p2 is the port number.
...........................
Does it mean it is 3X256+223=991 is the data port for passive mode for me?

Thanks
Sowjanya
0 votes
by (161k points)
Yes. Interestingly, you say that the admin has opened this port. And yet the client is failing to connect on the port.

Either the port isn't open, or there may be more than one firewall in operation.
0 votes
by (480 points)
I see the following lines in the filezilla log relating to the passive mode switch. Looks like it was able to switch to PASV mode but not able to execute the LIST command

Command: PASV
Response: 227 Entering Passive Mode (65,164,177,134,3,223)
Command: LIST
Response: 150 File status okay; about to open data connection
Response: 150 Opening secure data connection.
Error: Failed to retrieve directory listing
Status: Disconnected from server
0 votes
by (161k points)
Yes, a firewall is preventing the connection on the data port 991
0 votes
by (480 points)
I will double check with my admin again about it.
But if that port was blocked, how could our vendor have received the file I sent them?

Thanks
Sowjanya

Categories

...