我正在與我的ProFTPD服務器工作的基本FTP傳輸的應用程序傳輸文件的ProFTPD服務器。無法從外部IP
在本地網絡中,下面的代碼工作。然而,當我使用此代碼,並嘗試通過外部IP連接,(是的,我改變了IP到我的外部IP),我得到的錯誤:
sun.net.ftp.FtpProtocolException: PORT :500 Illegal PORT command, EPSV ALL in effect
此外,連接到FTP服務器在瀏覽器會導致外部IP延遲一分鐘或兩分鐘,但我不知道這是否與此有關。
這裏是我的代碼:
URL url=new URL("ftp://"+username+":"+password+"@"+ip+path+recipient+"/"+sendMe.getName());
URLConnection con=url.openConnection();
System.out.println("connected");
FileInputStream input=new FileInputStream(sendMe);
BufferedOutputStream output=new BufferedOutputStream(con.getOutputStream());
System.out.println("output Stream");
int c;
int size=0;
TransferDialog transfer=new TransferDialog("0 bytes processed");
while ((c = input.read()) != -1) {
output.write(c);
size++;
transfer.changeText(size+" bytes processed");
System.out.println(size);
}
if (input != null) {
input.close();
}
if (output != null) {
output.close();
}
System.out.println("Uploaded");
當這個運行時,發生了錯誤,而不是「輸出流」的消息。任何幫助或建議表示讚賞!
這是不是一個真正的java的問題,這是關於如何配置你的FTP服務器正常工作,更對serverfault.com問題(減去的Java位)。 – skaffman 2012-02-09 15:39:00