Follow this Blog!

Jul 12, 2016

f Comment

I Cannot Download Files from an FTP Server in my IDE. How Do I Fix It?

Amazon If you use an IDE such as Eclipse or NetBeans to download and edit files from an FTP server, you may encounter the problem where you can connect to the FTP server, but it keeps hanging until it times out. How do you fix the problem where you cannot download files from your FTP server although you have the right username and password?

This solution applies to any FTP client you use.

Root Cause

In my case, the cause of the problem is because my IDE cannot understand the response from the FTP server due to unexpected character encoding. To my IDE, the response looks like garbage. Therefore they cannot understand each other, and my IDE just freezes and hangs until the FTP connection times out. How annoying.

Solution

In the FTP setting, you must set the character set or character encoding to "Default from remote system" or "use font encoding". The wording may be different depending on the IDE you are using, but select the option that allows you to use the default character encoding from the FTP server.

This will make sure your IDE is communicating with the FTP server in the correct character encoding. When my FTP client successfully downloads the files of the root folder from the remote FTP server, the log looks like the following:

220 ::ffff:x.x.x.x FTP 伺服器準備就緒

USER username
331 需要為 username 提供密碼

PASS ******
230-...

230 使用者 username 登入

SYST
215 UNIX Type: L8

TYPE I
200 類型設定為 I

PWD
257 現行目錄是 "/"

NOOP
200 NOOP 命令成功執行

CWD /
250 CWD 命令成功執行

PORT x,x,x,x,x,x
200 PORT 命令成功執行

LIST -a
150 開啟 BINARY 模式的資料連接為 file list

226 傳送完畢

..list of files..

My question is how does the IDE know the default encoding from the server? My theory is when IDE gets a response from FTP, it would read the first few bytes of the response to know what encoding the characters are. If you know the answer for sure please let me know!

Questions? Let me know!
Please leave a comment here!
One Minute Information - by Michael Wen
Find Michael on Google or Facebook
ADVERTISING WITH US - Direct your advertising requests to Michael