Java FTPClient storeFile Hangs Forever on First time Invocation

I was using ftp-clj to upload file to server from Clojure REPL, what I observed is on first invocation of client-put which just a wrapper of invocation of storeFile method of Java class FTPClient, it occasionally hangs, the first invocation here means the method hasn't been used for a while like several days, I don't know it failed or succeeded, just hang there without any report. So I have to open a new REPL and execute the command again, and usually it will upload immediately without any delay.

If I leave the REPL open and wait for long enough time, the following error is thrown:

FTP response 421 received.  Server closed connection.
FTPConnectionClosedException FTP response 421 received.  Server closed connection. (

The response code 421 means service not available, closing control connection. It indicates that while the service is still running, the service is unavailable at the time of connection. It usually indicates that the server will be restarting as soon as it finishes processing of pending operations (usually any file transfers currently in progress). It is considered a transient negative response, which means the client is encouraged to issue the same command again at a later time when it may be accepted.

When connect succeed, the control connection is set up, but when try to upload file, for some reasons the service decided that it must shutdown, so the upload failed.

(defn may-hang [client]
  ; make a dumb upload and wait a timeout for 1 secs
  (future (do
    (ftp/client-put "c:\\Pictures\\dumb.jpg")
    (println "succeed uploading dumb.jpg")
  (println "wait for 1 sec for ")
  (Thread/sleep 1000)

Here is how to use it

  (ftp/with-ftp [client ftp-image-path :file-type :binary]
    (may-hang client)
  (ftp/with-ftp [client ftp-image-path :file-type :binary]
    ;; do real uploading here