FTPSClient返回MalformedServerReplyException:无法解析响应代码

bou*_*ppo 4 java ftps apache-commons

我有一个SFTP连接设置.我使用WinCSP和Filezilla,测试服务器没有问题.java代码来自于apache commons-net 2.0它,它给了我意想不到的错误

private String ftpServer="XXX.xx.x.XX";
private int ftpPort=99;
private String ftpUserName="myUserName";
private String ftpPassword="myPassword";

FTPSClient ftp = null;
        try{
            ftp = new FTPSClient();
            ftp.connect(hostname, port)
        } catch (Exception e){
           Logger.debug(e)
        }
Run Code Online (Sandbox Code Playgroud)

堆栈跟踪

Server reply:SSH-2.0-WeOnlyDo-wodFTPD 2.3.6.165
org.apache.commons.net.MalformedServerReplyException: Could not parse response code.
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:315)
    at org.apache.commons.net.ftp.FTP._connectAction_(FTP.java:364)
    at org.apache.commons.net.ftp.FTPClient._connectAction_(FTPClient.java:540)
    at org.apache.commons.net.ftp.FTPSClient._connectAction_(FTPSClient.java:167)
    at org.apache.commons.net.SocketClient.connect(SocketClient.java:178)
    at myHomeFtpService.getFtpConnection(HomeFtpService.java:40)
Run Code Online (Sandbox Code Playgroud)

Ray*_*Tau 12

由于您使用FTP客户端连接到SSH服务器.FTPS和SFTP是两种不同的协议.

WinSCP和Filezilla都可以正常工作,因为它们支持SFTP.