After stepping through in the debugger, I found out that the ftpClient.completePendingCommand()
call was causing the timeout. I guess the command was already completed and it was waiting for the next command indefinitely. I commented out that line and the code completed easily.
From the JavaDoc on FTPClient: http://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/ftp/FTPClient.html#completePendingCommand()
There are a few FTPClient methods that do not complete the entire sequence of FTP commands to complete a transaction. These commands require some action by the programmer after the reception of a positive intermediate command. After the programmer's code completes its actions, it must call this method to receive the completion reply from the server and verify the success of the entire transaction.
I guess storeFile()
(the FTP STOR command) isn't one of those methods.