Android Problem mit Upload auf FTP Server


#1
Hallo Leute,

ich hoffe jemand von euch kann mir weiterhelfen. Ich versuche vergebens eine Datei (pdf und txt getestet) auf mein FTP Server (FritzBox mit USBStick und aktiviertem FTPS) hochzuladen. Der Anmeldung funktioniert. Die Datei ist dann auch im angegebenen Verzeichnis gelandet. Nur leider leer. Kann es sein das ich noch irgendeine Config mitgeben muss zwecks Zeitzone oder so. Hab dazu mal irgendwas gelesen. Nur merkwürdig das die Anmeldung klappt aber nicht die Übertragung?!
Ich benutze die commons API von Apache.
storFile liefert auch keine Exception sondern ist einfach nur false. Nachdem ich mir StoreFile genauer angesehen habe vermute ich das bei soket=_openDataConnection was schief läuft. kann es aber nicht Überprüfen :(

Achso und ich nutze dafür ein AsyncTask

Code:
public boolean toServerViaFtp(){

        boolean     successful = false;
        FTPSClient   mFTPSClient;

        Log.d( LOG_TAG , "toServerViaFtp - start" );

        try {

            // Verbinde mit Server
            mFTPSClient = new FTPSClient("TLS");
         
            KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
            kmf.init(null, null);
            KeyManager km = kmf.getKeyManagers()[0];
            mFTPSClient.setKeyManager(km);

            // connecting to the host
            mFTPSClient.connect("name.host.eu", 21);
            boolean status = mFTPSClient.login("uName", "Passw");
            Log.d( LOG_TAG , "login-status: " + status );
            // now check the reply code, if positive mean connection success
            if (FTPReply.isPositiveCompletion(mFTPSClient.getReplyCode())) {
              // Set File Transfer Mode
         
                mFTPSClient.setFileType(FTPSClient.BINARY_FILE_TYPE);
                mFTPSClient.enterLocalPassiveMode();
            }

            // Dateiupload
            String srcFilePath = Environment.getExternalStorageDirectory() + "/Vertraege/Pool.pdf";
            String desFileName = "/Intenso-TwisterLine-01/VertraegeAPP/Pool.pdf";
            FileInputStream srcFileStream = new FileInputStream(srcFilePath);
         
            status = mFTPSClient.storeFile(desFileName, srcFileStream);
            Log.d(LOG_TAG, "Store File = " + status);
         
            srcFileStream.close();

            // Verbindung schließen
            mFTPSClient.logout();
            mFTPSClient.disconnect();
            Log.d(LOG_TAG, "Verbindung getrennt");

            successful = true;

        } catch (IOException ioe) {
            ioe.printStackTrace();
            Log.d( LOG_TAG , "FEHLER: " + ioe );

        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            Log.d(LOG_TAG, "FEHLER: " + e);
        } catch (UnrecoverableKeyException urke) {
            urke.printStackTrace();
            Log.d(LOG_TAG, "FEHLER: " + urke);
        } catch (KeyStoreException kse) {
            kse.printStackTrace();
            Log.d(LOG_TAG, "FEHLER: " + kse);
        }

        return successful;

    }

Code:
private boolean __storeFile(int command, String remote, InputStream local)
throws IOException
{
    OutputStream output;
    Socket socket;

    if ((socket = _openDataConnection_(command, remote)) == null)
        return false;

    output = new BufferedOutputStream(socket.getOutputStream(),
            getBufferSize()
    );
    if (__fileType == ASCII_FILE_TYPE)
        output = new ToNetASCIIOutputStream(output);
    // Treat everything else as binary for now
    try
    {
        Util.copyStream(local, output, getBufferSize(),
                CopyStreamEvent.UNKNOWN_STREAM_SIZE, null,
                false);
    }
    catch (IOException e)
    {
        try
        {
            socket.close();
        }
        catch (IOException f)
        {}
        throw e;
    }
    output.close();
    socket.close();
    return completePendingCommand();
}

Code:
D/MainActivity: toServerViaFtp - start

W/Trace:    Unexpected value from nativeGetEnabledTags: 0
D/libc-netbsd:    getaddrinfo: name.host.eu get result from proxy >>
I/System.out:    propertyValue:true
I/System.out:    [socket][2] connection name.host.eu/meineIP:21;LocalPort=51668(0)
I/System.out:    [CDS]connect[name.host.eu/meineIP:21] tm:90
D/Posix:    [Posix_connect Debug]Process de.meine.app :21
I/System.out:    [socket][/192.168.178.31:51668] connected
I/System.out:    [CDS]rx timeout:0
W/Trace:    Unexpected value from nativeGetEnabledTags: 0
D/dalvikvm:    GC_CONCURRENT freed 379K, 5% free 11717K/12268K, paused 3ms+5ms, total 32ms
D/jdwp:    sendBufferedRequest : len=0x34
W/Trace:    Unexpected value from nativeGetEnabledTags: 0
D/NativeCrypto: ssl=0x5ff7db18 NativeCrypto_SSL_do_handshake fd=0x20300005 shc=0x21a00009 timeout_millis=0 client_mode=1 npn=0x0
D/NativeCrypto: doing handshake ++
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x10 ret=1
D/NativeCrypto: ssl=0x5ff7db18 handshake start in UNKWN  before/connect initialization
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:UNKWN  before/connect initialization
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:23WCHA SSLv2/v3 write client hello A
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1002 ret=-1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:error exit in 23RSHA SSLv2/v3 read server hello A
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: doing handshake -- ret=-1
D/NativeCrypto: ssl=0x5ff7db18 NativeCrypto_SSL_do_handshake ret=-1 errno=11 sslError=2 timeout_millis=0
D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
D/NativeCrypto: doing handshake ++
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3RSH_A SSLv3 read server hello A
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored

E/NativeCrypto: ssl=0x5ff7db18 cert_verify_callback x509_store_ctx=0x60098a40 arg=0x0
E/NativeCrypto: ssl=0x5ff7db18 cert_verify_callback calling verifyCertificateChain authMethod=RSA

D/NativeCrypto: ssl=0x5ff7db18 cert_verify_callback => 1
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3RSC_A SSLv3 read server certificate A
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3RSD_A SSLv3 read server done A
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3WCKEA SSLv3 write client key exchange A
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/jdwp:    processIncoming
D/jdwp:    handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400069E0, flags=0x0, dataLen=0x9
D/jdwp:    sendBufferedRequest : len=0x34
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3WCCSA SSLv3 write change cipher spec A
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3WFINA SSLv3 write finished A
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3FLUSH SSLv3 flush data
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1002 ret=-1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:error exit in 3RFINA SSLv3 read finished A
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1002 ret=-1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:error exit in 3RFINA SSLv3 read finished A
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: doing handshake -- ret=-1
D/NativeCrypto: ssl=0x5ff7db18 NativeCrypto_SSL_do_handshake ret=-1 errno=11 sslError=2 timeout_millis=0
D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
D/NativeCrypto: doing handshake ++
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3RFINA SSLv3 read finished A
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x20 ret=1
D/NativeCrypto: ssl=0x5ff7db18 handshake done in SSLOK  SSL negotiation finished successfully
D/NativeCrypto: ssl=0x5ff7db18 info_callback calling handshakeCompleted
D/NativeCrypto: ssl=0x5ff7db18 info_callback completed
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1002 ret=1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:ok exit in SSLOK  SSL negotiation finished successfully
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: doing handshake -- ret=1
D/NativeCrypto: ssl=0x5ff7db18 NativeCrypto_SSL_get_certificate => NULL

D/MainActivity: connected

D/NativeCrypto: ssl=0x5ff7db18 sslWrite buf=0x41c08c50 len=16 write_timeout_millis=0
D/NativeCrypto: Doing SSL_write() with 16 bytes to go ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_write() with result 16, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: ssl=0x5ff7db18 sslRead buf=0x41c0e270 len=8192,timeo=0
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result -1, error code 2 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result 38, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: ssl=0x5ff7db18 sslWrite buf=0x41c08c50 len=15 write_timeout_millis=0
D/NativeCrypto: Doing SSL_write() with 15 bytes to go ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_write() with result 15, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: ssl=0x5ff7db18 sslRead buf=0x41c0e296 len=8154,timeo=0
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result -1, error code 2 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result 31, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0

D/MainActivity: login-status: true

D/NativeCrypto: ssl=0x5ff7db18 sslWrite buf=0x41c08c50 len=8 write_timeout_millis=0
D/NativeCrypto: Doing SSL_write() with 8 bytes to go ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_write() with result 8, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: ssl=0x5ff7db18 sslRead buf=0x41c0e2b5 len=8123,timeo=0
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result -1, error code 2 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result 20, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: ssl=0x5ff7db18 sslWrite buf=0x41c08c50 len=6 write_timeout_millis=0
D/NativeCrypto: Doing SSL_write() with 6 bytes to go ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_write() with result 6, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: ssl=0x5ff7db18 sslRead buf=0x41c0e2c9 len=8103,timeo=0
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result -1, error code 2 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result 46, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
I/System.out:    [CDS]connect[/meineIP:56629] tm:90
D/Posix:    [Posix_connect Debug]Process de.meine.app :56629
D/NativeCrypto: ssl=0x5ff7db18 sslWrite buf=0x41c08c50 len=52 write_timeout_millis=0
D/NativeCrypto: Doing SSL_write() with 52 bytes to go ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_write() with result 52, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: ssl=0x5ff7db18 sslRead buf=0x41c0e2f7 len=8057,timeo=0
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result -1, error code 2 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result 52, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
I/System.out:    [CDS]close[48049]
I/System.out:    close [socket][/0.0.0.0:48049]

D/MainActivity: Store File = false

D/NativeCrypto: ssl=0x5ff7db18 sslWrite buf=0x41c08c50 len=6 write_timeout_millis=0
D/NativeCrypto: Doing SSL_write() with 6 bytes to go ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_write() with result 6, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: ssl=0x5ff7db18 sslRead buf=0x41c0e32b len=8005,timeo=0
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result -1, error code 2 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result 14, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: ssl=0x5ff7db18 NativeCrypto_SSL_interrupt
D/NativeCrypto:  sslNotify, appData=0x5fd4e2d0 ret=1
D/NativeCrypto:  sslNotify, appData=0x5fd4e2d0 ret=1
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x4008 ret=256
D/NativeCrypto: ssl=0x5ff7db18 SSL3 alert write:W:CN warning close notify
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
I/System.out:    [CDS]close[51668]
I/System.out:    close [socket][/0.0.0.0:51668]

D/MainActivity: ausgelogt und getrennt