Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.3k views
in Java FTP by (200 points)
Using FileTransferClient, I'm trying to upload a small html file onto the server (it's only a few bytes). For some reason, it's started giving me a read timeout error. I say started because up to a couple days ago this wasn't happening. I don't know what I did to break it. Here's the relevant code:

   String postLoc = System.getProperty("java.io.tmpdir") +  "/" + postName + ".html";
   putFileContents(postLoc, file);
   try {
       ftpManager.uploadFile(postLoc, postName + ".html");
       ftpManager.disconnect();
   } catch (FTPException f1) {
       iom.showError(f1);
   } catch (IOException e1) {
       iom.showError(e1);
   }


The only error given is:
java.net.SocketTimeoutException: Read timed out.

I'm running this from a command line, with my desktop as the working directory, and from Fedora. The tmpdir variable is simply "/tmp".

No matter what timeout I've set it to this still happens. All it does is create an empty file on the server, but doesn't put any of the content into the remote file.

If it's relevant, I am unable to ftp to my server through a command line and issue the following commands:
quote PASV
quote LIST

The first one works to put it into passive mode, but it hangs up on the second. This also happens if I try to use a STOR command.

4 Answers

0 votes
by (162k points)
Post a log file. It could be a firewall change - try switching from passive to active mode. Can you transfer the file with another client such as Filezilla?
0 votes
by (200 points)
Trying a "quote PORT " also times out. As for a separate FTP client, I know that FireFTP through Firefox works just fine. I am unable to install Filezilla at this time. Here's the log file:

It's long, but I'm not sure what part of it you want to see. Most of it's the same stuff. I've bolded and underlined the parts that are different.
DEBUG [FTPClient] 30 Apr 2008 09:18:19.474 : Class: com.enterprisedt.net.ftp.FTPClient
Version: 2.0.2
Build timestamp: 31-Mar-2008 14:30:20 EST
Java version: 1.6.0_04
CLASSPATH: .:S4/edtftpj-2.0.2/lib/edtftpj.jar
OS name: Linux
OS arch: i386
OS version: 2.6.23.15-80.fc7

DEBUG [FileTransferClient] 30 Apr 2008 09:18:19.481 : Configured client
DEBUG [FTPClient] 30 Apr 2008 09:18:19.482 : Connecting to web228.ixwebhosting.com/76.162.253.45:21
DEBUG [SocketUtils] 30 Apr 2008 09:18:19.493 : Invoking connect with timeout=60000
DEBUG [SocketUtils] 30 Apr 2008 09:18:19.523 : Connected successfully
DEBUG [FTPControlSocket] 30 Apr 2008 09:18:19.552 : 220 ProFTPD 1.2.9 Server (Main FTP Server) [web228.opentransfer.com]
DEBUG [FileTransferClient] 30 Apr 2008 09:18:19.554 : Client connected
DEBUG [FileTransferClient] 30 Apr 2008 09:18:19.554 : Logging in
DEBUG [FTPControlSocket] 30 Apr 2008 09:18:19.554 : ---> USER ^^^^^^^
DEBUG [FTPControlSocket] 30 Apr 2008 09:18:19.648 : 331 Password required for ^^^^^^^.
DEBUG [FTPControlSocket] 30 Apr 2008 09:18:19.648 : ---> PASS ********
DEBUG [FTPControlSocket] 30 Apr 2008 09:18:19.793 : 230 User bvcodice logged in.
DEBUG [FileTransferClient] 30 Apr 2008 09:18:19.793 : Logged in
DEBUG [FTPControlSocket] 30 Apr 2008 09:18:19.794 : ---> TYPE I
DEBUG [FTPControlSocket] 30 Apr 2008 09:18:19.820 : 200 Type set to I
DEBUG [FTPControlSocket] 30 Apr 2008 09:18:19.821 : ---> CWD /news
DEBUG [FTPControlSocket] 30 Apr 2008 09:18:19.853 : 250 CWD command successful.
DEBUG [FTPControlSocket] 30 Apr 2008 09:18:19.893 : ListenOnAllInterfaces=true
DEBUG [FTPControlSocket] 30 Apr 2008 09:18:19.895 : ---> PORT 146,57,33,122,149,98
DEBUG [FTPControlSocket] 30 Apr 2008 09:18:19.933 : 200 PORT command successful
DEBUG [FTPControlSocket] 30 Apr 2008 09:18:19.934 : ---> STOR 04-30-2008-new-post.html
ERROR [FTPClient] 30 Apr 2008 09:19:19.933 : Caught and rethrowing exception in initPut() : 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.readBytes(StreamDecoder.java:264)
   at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
   at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
   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:850)
   at com.enterprisedt.net.ftp.FTPControlSocket.sendCommand(FTPControlSocket.java:818)
   at com.enterprisedt.net.ftp.FTPClient.initPut(FTPClient.java:2258)
   at com.enterprisedt.net.ftp.FTPClient.putData(FTPClient.java:2322)
   at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:2065)
   at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:2047)
   at com.enterprisedt.net.ftp.FileTransferClient.uploadFile(FileTransferClient.java:639)
   at com.enterprisedt.net.ftp.FileTransferClient.uploadFile(FileTransferClient.java:613)
0 votes
by (51.6k points)
It seems clear that your socket time-out is set to 60 seconds and that it's simply timing out as it's trying to connect the data-channel. This usually happens when there's a firewall in the way.

It's not clear from your reply if tried using passive mode instead of active mode?

It's done using:
ftp.getAdvancedFTPSettings().setConnectMode(FTPConnectMode.PASV);


- Hans (EnterpriseDT)
0 votes
by (200 points)
I apologize for the timeout confusion; that log is from after I changes the timeout I had been trying to a more reasonable number.

However, changing to PASV has fixed all my problems! I can finally get some actual work done! Thank you!

Categories

...