Ftp客户端无法使用IPV6传输文件

我正在编写通过ftp发送文件的Java代码,如下所示。我使用的服务器是本地主机上的FileZilla Server软件。Ftp客户端无法使用IPV6传输文件

public static void main(String[] args) { 

try {

String host = "fe80::21a:a0ff:fe8d:fe63"; //No problem if ipv4

int port = 1998;

String username = "joe";

String password = "123";

String directory = "D:/ftp_share";

File fileToTransfer = new File("D:/RND/samplefile.txt");

String fileName = fileToTransfer.getName();

FTPClient ftp = new FTPClient();

ftp.connect(host, port);

ftp.login(username, password);

FileInputStream in = new FileInputStream(fileToTransfer);

if (!(directory == null || "".equals(directory))) {

ftp.changeWorkingDirectory(directory);

}

ftp.setFileType(FTP.BINARY_FILE_TYPE);

ftp.appendFile(fileName, (InputStream) in);

System.out.println("File " + fileName + " succesfully sent via ftp to " + host + " at port " + port);

} catch (SocketException ex) {

Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);

} catch (IOException ex) {

Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);

}

}

问题是我只能发送通过IPV4但不使用IPv6。在Java exeption是

org.apache.commons.net.ftp.FTPConnectionClosedException: FTP response 421 received. Server closed connection. 

at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:360)

at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:290)

at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:474)

at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:547)

at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:680)

at org.apache.commons.net.ftp.FTPClient.__storeFile(FTPClient.java:551)

at org.apache.commons.net.ftp.FTPClient.appendFile(FTPClient.java:1765)

at rnd.Main.main(Main.java:44)

,并在文件服务器吉拉的消息是

(000018)10/18/2011 14:46:39 PM - (not logged in) (fe80::21a:a0ff:fe8d:fe63)> Connected, sending welcome message... 

(000018)10/18/2011 14:46:39 PM - (not logged in) (fe80::21a:a0ff:fe8d:fe63)> 220-FileZilla Server version 0.9.39 beta

(000018)10/18/2011 14:46:39 PM - (not logged in) (fe80::21a:a0ff:fe8d:fe63)> 220-written by Tim Kosse ([email protected])

(000018)10/18/2011 14:46:39 PM - (not logged in) (fe80::21a:a0ff:fe8d:fe63)> 220 Please visit http://sourceforge.net/projects/filezilla/

(000018)10/18/2011 14:46:39 PM - (not logged in) (fe80::21a:a0ff:fe8d:fe63)> USER joe

(000018)10/18/2011 14:46:39 PM - (not logged in) (fe80::21a:a0ff:fe8d:fe63)> 331 Password required for joe

(000018)10/18/2011 14:46:39 PM - (not logged in) (fe80::21a:a0ff:fe8d:fe63)> PASS ***

(000018)10/18/2011 14:46:39 PM - joe (fe80::21a:a0ff:fe8d:fe63)> 230 Logged on

(000018)10/18/2011 14:46:39 PM - joe (fe80::21a:a0ff:fe8d:fe63)> CWD D:/RND/ftp_share

(000018)10/18/2011 14:46:39 PM - joe (fe80::21a:a0ff:fe8d:fe63)> 550 CWD failed. "/D:/RND/ftp_share": directory not found.

(000018)10/18/2011 14:46:39 PM - joe (fe80::21a:a0ff:fe8d:fe63)> TYPE I

(000018)10/18/2011 14:46:39 PM - joe (fe80::21a:a0ff:fe8d:fe63)> 200 Type set to I

(000018)10/18/2011 14:46:39 PM - joe (fe80::21a:a0ff:fe8d:fe63)> EPRT |1|0.0.0.0|2885|

(000018)10/18/2011 14:46:39 PM - joe (fe80::21a:a0ff:fe8d:fe63)> 200 Port command successful

(000018)10/18/2011 14:46:39 PM - joe (fe80::21a:a0ff:fe8d:fe63)> APPE jawapannya.txt

(000018)10/18/2011 14:46:39 PM - joe (fe80::21a:a0ff:fe8d:fe63)> 421 Can't create socket

可以在任何1和帮助,如何使人们有可能使用IPv6发送。

注:我已经在我的本地IPV6。

回答:

该EPRT命令是虚假的,它正在请求服务器连接到未指定的IPv4地址。

它可能更适用于本地主机地址:: 1或全局地址,而不是链接本地地址。

以上是 Ftp客户端无法使用IPV6传输文件 的全部内容, 来源链接: utcz.com/qa/261673.html

回到顶部