1

当我使用 client.connect(FTP_HOST); 时,我得到了这个错误。我有标准的 ftp 连接并使用默认端口 21 任何人都可以帮我找出这个问题的原因是什么?谢谢

it.sauronsoftware.ftp4j.FTPClient [connected=false,
connector=it.sauronsoftware.ftp4j.connectors.DirectConnector@4281bfb8,
security=SECURITY_FTP, authenticated=false, transfer mode=passive, 
transfer type=TYPE_AUTO, textualExtensionRecognizer=it.sauronsoftware.ftp4j.extrecognizers.DefaultTextualExtensionRecognizer@4281ccd0, 
listParsers=it.sauronsoftware.ftp4j.listparsers.UnixListParser@42872d30, 
it.sauronsoftware.ftp4j.listparsers.DOSListParser@42870a40, 
it.sauronsoftware.ftp4j.listparsers.EPLFListParser@4284c9f8, 
it.sauronsoftware.ftp4j.listparsers.NetWareListParser@428698d0, 
it.sauronsoftware.ftp4j.listparsers.MLSDListParser@4284e2b8, autoNoopTimeout=0]

// 这是我的代码

public void uploadFile(File fileName){


    FTPClient client = new FTPClient();

    try {

        client.connect(FTP_HOST);
        client.login(FTP_USER, FTP_PASS);
        client.setType(FTPClient.TYPE_BINARY);
        //client.changeDirectory("/schlogger/");

        client.upload(fileName, new MyTransferListener());

    } catch (Exception e) {
        e.printStackTrace();
        try {
            client.disconnect(true);
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

}

这是主要的

<uses-permission android:name="android.permission.INTERNET"></uses-permission>
4

1 回答 1

1

尝试在client.setType(FTPClient.TYPE_BINARY);代码后添加client.setPassive(true); client.noop();

于 2014-07-14T14:10:12.807 回答