asmgx
asmgx

Reputation: 8004

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>

Upvotes: 1

Views: 2530

Answers (1)

Tapa Save
Tapa Save

Reputation: 4857

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

Upvotes: 1

Related Questions