简体   繁体   中英

Error connecting to FTP server using ftp4j in android

I get this error exactly when I use client.connect(FTP_HOST); I have standard ftp connection and using the default port 21 anyone can help me find what is the cause of this problem? thanks

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]

// This is my code

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();
        }
    }

}

this is in the mainfist

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

Try add after client.setType(FTPClient.TYPE_BINARY); code client.setPassive(true); client.noop(); client.setPassive(true); client.noop();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM