1. Diese Seite verwendet Cookies. Wenn du dich weiterhin auf dieser Seite aufhältst, akzeptierst du unseren Einsatz von Cookies. Weitere Informationen

Android Problem mit Upload auf FTP Server

Dieses Thema im Forum "Java Mobile, Android, J2ME, Blackberry" wurde erstellt von braesident, 13. Januar 2016.

  1. braesident

    braesident Grünschnabel

    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 (Text):
    1. public boolean toServerViaFtp(){
    2.  
    3.         boolean     successful = false;
    4.         FTPSClient   mFTPSClient;
    5.  
    6.         Log.d( LOG_TAG , "toServerViaFtp - start" );
    7.  
    8.         try {
    9.  
    10.             // Verbinde mit Server
    11.             mFTPSClient = new FTPSClient("TLS");
    12.          
    13.             KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
    14.             kmf.init(null, null);
    15.             KeyManager km = kmf.getKeyManagers()[0];
    16.             mFTPSClient.setKeyManager(km);
    17.  
    18.             // connecting to the host
    19.             mFTPSClient.connect("name.host.eu", 21);
    20.             boolean status = mFTPSClient.login("uName", "Passw");
    21.             Log.d( LOG_TAG , "login-status: " + status );
    22.             // now check the reply code, if positive mean connection success
    23.             if (FTPReply.isPositiveCompletion(mFTPSClient.getReplyCode())) {
    24.               // Set File Transfer Mode
    25.          
    26.                 mFTPSClient.setFileType(FTPSClient.BINARY_FILE_TYPE);
    27.                 mFTPSClient.enterLocalPassiveMode();
    28.             }
    29.  
    30.             // Dateiupload
    31.             String srcFilePath = Environment.getExternalStorageDirectory() + "/Vertraege/Pool.pdf";
    32.             String desFileName = "/Intenso-TwisterLine-01/VertraegeAPP/Pool.pdf";
    33.             FileInputStream srcFileStream = new FileInputStream(srcFilePath);
    34.          
    35.             status = mFTPSClient.storeFile(desFileName, srcFileStream);
    36.             Log.d(LOG_TAG, "Store File = " + status);
    37.          
    38.             srcFileStream.close();
    39.  
    40.             // Verbindung schließen
    41.             mFTPSClient.logout();
    42.             mFTPSClient.disconnect();
    43.             Log.d(LOG_TAG, "Verbindung getrennt");
    44.  
    45.             successful = true;
    46.  
    47.         } catch (IOException ioe) {
    48.             ioe.printStackTrace();
    49.             Log.d( LOG_TAG , "FEHLER: " + ioe );
    50.  
    51.         } catch (NoSuchAlgorithmException e) {
    52.             e.printStackTrace();
    53.             Log.d(LOG_TAG, "FEHLER: " + e);
    54.         } catch (UnrecoverableKeyException urke) {
    55.             urke.printStackTrace();
    56.             Log.d(LOG_TAG, "FEHLER: " + urke);
    57.         } catch (KeyStoreException kse) {
    58.             kse.printStackTrace();
    59.             Log.d(LOG_TAG, "FEHLER: " + kse);
    60.         }
    61.  
    62.         return successful;
    63.  
    64.     }

    Code (Text):
    1. private boolean __storeFile(int command, String remote, InputStream local)
    2. throws IOException
    3. {
    4.     OutputStream output;
    5.     Socket socket;
    6.  
    7.     if ((socket = _openDataConnection_(command, remote)) == null)
    8.         return false;
    9.  
    10.     output = new BufferedOutputStream(socket.getOutputStream(),
    11.             getBufferSize()
    12.     );
    13.     if (__fileType == ASCII_FILE_TYPE)
    14.         output = new ToNetASCIIOutputStream(output);
    15.     // Treat everything else as binary for now
    16.     try
    17.     {
    18.         Util.copyStream(local, output, getBufferSize(),
    19.                 CopyStreamEvent.UNKNOWN_STREAM_SIZE, null,
    20.                 false);
    21.     }
    22.     catch (IOException e)
    23.     {
    24.         try
    25.         {
    26.             socket.close();
    27.         }
    28.         catch (IOException f)
    29.         {}
    30.         throw e;
    31.     }
    32.     output.close();
    33.     socket.close();
    34.     return completePendingCommand();
    35. }

    Code (Text):
    1. D/MainActivity: toServerViaFtp - start
    2.  
    3. W/Trace:    Unexpected value from nativeGetEnabledTags: 0
    4. D/libc-netbsd:    getaddrinfo: name.host.eu get result from proxy >>
    5. I/System.out:    propertyValue:true
    6. I/System.out:    [socket][2] connection name.host.eu/meineIP:21;LocalPort=51668(0)
    7. I/System.out:    [CDS]connect[name.host.eu/meineIP:21] tm:90
    8. D/Posix:    [Posix_connect Debug]Process de.meine.app :21
    9. I/System.out:    [socket][/192.168.178.31:51668] connected
    10. I/System.out:    [CDS]rx timeout:0
    11. W/Trace:    Unexpected value from nativeGetEnabledTags: 0
    12. D/dalvikvm:    GC_CONCURRENT freed 379K, 5% free 11717K/12268K, paused 3ms+5ms, total 32ms
    13. D/jdwp:    sendBufferedRequest : len=0x34
    14. W/Trace:    Unexpected value from nativeGetEnabledTags: 0
    15. D/NativeCrypto: ssl=0x5ff7db18 NativeCrypto_SSL_do_handshake fd=0x20300005 shc=0x21a00009 timeout_millis=0 client_mode=1 npn=0x0
    16. D/NativeCrypto: doing handshake ++
    17. D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x10 ret=1
    18. D/NativeCrypto: ssl=0x5ff7db18 handshake start in UNKWN  before/connect initialization
    19. D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
    20. D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
    21. D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:UNKWN  before/connect initialization
    22. D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
    23. D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
    24. D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:23WCHA SSLv2/v3 write client hello A
    25. D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
    26. D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1002 ret=-1
    27. D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:error exit in 23RSHA SSLv2/v3 read server hello A
    28. D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
    29. D/NativeCrypto: doing handshake -- ret=-1
    30. D/NativeCrypto: ssl=0x5ff7db18 NativeCrypto_SSL_do_handshake ret=-1 errno=11 sslError=2 timeout_millis=0
    31. D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
    32. D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
    33. D/NativeCrypto: doing handshake ++
    34. D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
    35. D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3RSH_A SSLv3 read server hello A
    36. D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
    37.  
    38. E/NativeCrypto: ssl=0x5ff7db18 cert_verify_callback x509_store_ctx=0x60098a40 arg=0x0
    39. E/NativeCrypto: ssl=0x5ff7db18 cert_verify_callback calling verifyCertificateChain authMethod=RSA
    40.  
    41. D/NativeCrypto: ssl=0x5ff7db18 cert_verify_callback => 1
    42. D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
    43. D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3RSC_A SSLv3 read server certificate A
    44. D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
    45. D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
    46. D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3RSD_A SSLv3 read server done A
    47. D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
    48. D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
    49. D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3WCKEA SSLv3 write client key exchange A
    50. D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
    51. D/jdwp:    processIncoming
    52. D/jdwp:    handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400069E0, flags=0x0, dataLen=0x9
    53. D/jdwp:    sendBufferedRequest : len=0x34
    54. D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
    55. D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3WCCSA SSLv3 write change cipher spec A
    56. D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
    57. D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
    58. D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3WFINA SSLv3 write finished A
    59. D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
    60. D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
    61. D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3FLUSH SSLv3 flush data
    62. D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
    63. D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1002 ret=-1
    64. D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:error exit in 3RFINA SSLv3 read finished A
    65. D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
    66. D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1002 ret=-1
    67. D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:error exit in 3RFINA SSLv3 read finished A
    68. D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
    69. D/NativeCrypto: doing handshake -- ret=-1
    70. D/NativeCrypto: ssl=0x5ff7db18 NativeCrypto_SSL_do_handshake ret=-1 errno=11 sslError=2 timeout_millis=0
    71. D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
    72. D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
    73. D/NativeCrypto: doing handshake ++
    74. D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
    75. D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3RFINA SSLv3 read finished A
    76. D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
    77. D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x20 ret=1
    78. D/NativeCrypto: ssl=0x5ff7db18 handshake done in SSLOK  SSL negotiation finished successfully
    79. D/NativeCrypto: ssl=0x5ff7db18 info_callback calling handshakeCompleted
    80. D/NativeCrypto: ssl=0x5ff7db18 info_callback completed
    81. D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1002 ret=1
    82. D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:ok exit in SSLOK  SSL negotiation finished successfully
    83. D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
    84. D/NativeCrypto: doing handshake -- ret=1
    85. D/NativeCrypto: ssl=0x5ff7db18 NativeCrypto_SSL_get_certificate => NULL
    86.  
    87. D/MainActivity: connected
    88.  
    89. D/NativeCrypto: ssl=0x5ff7db18 sslWrite buf=0x41c08c50 len=16 write_timeout_millis=0
    90. D/NativeCrypto: Doing SSL_write() with 16 bytes to go ssl=0x5ff7db18, appData=0x5fd4e2d0
    91. D/NativeCrypto: Returned from SSL_write() with result 16, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
    92. D/NativeCrypto: ssl=0x5ff7db18 sslRead buf=0x41c0e270 len=8192,timeo=0
    93. D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
    94. D/NativeCrypto: Returned from SSL_Read() with result -1, error code 2 ssl=0x5ff7db18, appData=0x5fd4e2d0
    95. D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
    96. D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
    97. D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
    98. D/NativeCrypto: Returned from SSL_Read() with result 38, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
    99. D/NativeCrypto: ssl=0x5ff7db18 sslWrite buf=0x41c08c50 len=15 write_timeout_millis=0
    100. D/NativeCrypto: Doing SSL_write() with 15 bytes to go ssl=0x5ff7db18, appData=0x5fd4e2d0
    101. D/NativeCrypto: Returned from SSL_write() with result 15, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
    102. D/NativeCrypto: ssl=0x5ff7db18 sslRead buf=0x41c0e296 len=8154,timeo=0
    103. D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
    104. D/NativeCrypto: Returned from SSL_Read() with result -1, error code 2 ssl=0x5ff7db18, appData=0x5fd4e2d0
    105. D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
    106. D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
    107. D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
    108. D/NativeCrypto: Returned from SSL_Read() with result 31, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
    109.  
    110. D/MainActivity: login-status: true
    111.  
    112. D/NativeCrypto: ssl=0x5ff7db18 sslWrite buf=0x41c08c50 len=8 write_timeout_millis=0
    113. D/NativeCrypto: Doing SSL_write() with 8 bytes to go ssl=0x5ff7db18, appData=0x5fd4e2d0
    114. D/NativeCrypto: Returned from SSL_write() with result 8, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
    115. D/NativeCrypto: ssl=0x5ff7db18 sslRead buf=0x41c0e2b5 len=8123,timeo=0
    116. D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
    117. D/NativeCrypto: Returned from SSL_Read() with result -1, error code 2 ssl=0x5ff7db18, appData=0x5fd4e2d0
    118. D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
    119. D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
    120. D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
    121. D/NativeCrypto: Returned from SSL_Read() with result 20, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
    122. D/NativeCrypto: ssl=0x5ff7db18 sslWrite buf=0x41c08c50 len=6 write_timeout_millis=0
    123. D/NativeCrypto: Doing SSL_write() with 6 bytes to go ssl=0x5ff7db18, appData=0x5fd4e2d0
    124. D/NativeCrypto: Returned from SSL_write() with result 6, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
    125. D/NativeCrypto: ssl=0x5ff7db18 sslRead buf=0x41c0e2c9 len=8103,timeo=0
    126. D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
    127. D/NativeCrypto: Returned from SSL_Read() with result -1, error code 2 ssl=0x5ff7db18, appData=0x5fd4e2d0
    128. D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
    129. D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
    130. D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
    131. D/NativeCrypto: Returned from SSL_Read() with result 46, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
    132. I/System.out:    [CDS]connect[/meineIP:56629] tm:90
    133. D/Posix:    [Posix_connect Debug]Process de.meine.app :56629
    134. D/NativeCrypto: ssl=0x5ff7db18 sslWrite buf=0x41c08c50 len=52 write_timeout_millis=0
    135. D/NativeCrypto: Doing SSL_write() with 52 bytes to go ssl=0x5ff7db18, appData=0x5fd4e2d0
    136. D/NativeCrypto: Returned from SSL_write() with result 52, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
    137. D/NativeCrypto: ssl=0x5ff7db18 sslRead buf=0x41c0e2f7 len=8057,timeo=0
    138. D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
    139. D/NativeCrypto: Returned from SSL_Read() with result -1, error code 2 ssl=0x5ff7db18, appData=0x5fd4e2d0
    140. D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
    141. D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
    142. D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
    143. D/NativeCrypto: Returned from SSL_Read() with result 52, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
    144. I/System.out:    [CDS]close[48049]
    145. I/System.out:    close [socket][/0.0.0.0:48049]
    146.  
    147. D/MainActivity: Store File = false
    148.  
    149. D/NativeCrypto: ssl=0x5ff7db18 sslWrite buf=0x41c08c50 len=6 write_timeout_millis=0
    150. D/NativeCrypto: Doing SSL_write() with 6 bytes to go ssl=0x5ff7db18, appData=0x5fd4e2d0
    151. D/NativeCrypto: Returned from SSL_write() with result 6, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
    152. D/NativeCrypto: ssl=0x5ff7db18 sslRead buf=0x41c0e32b len=8005,timeo=0
    153. D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
    154. D/NativeCrypto: Returned from SSL_Read() with result -1, error code 2 ssl=0x5ff7db18, appData=0x5fd4e2d0
    155. D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
    156. D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
    157. D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
    158. D/NativeCrypto: Returned from SSL_Read() with result 14, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
    159. D/NativeCrypto: ssl=0x5ff7db18 NativeCrypto_SSL_interrupt
    160. D/NativeCrypto:  sslNotify, appData=0x5fd4e2d0 ret=1
    161. D/NativeCrypto:  sslNotify, appData=0x5fd4e2d0 ret=1
    162. D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x4008 ret=256
    163. D/NativeCrypto: ssl=0x5ff7db18 SSL3 alert write:W:CN warning close notify
    164. D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
    165. I/System.out:    [CDS]close[51668]
    166. I/System.out:    close [socket][/0.0.0.0:51668]
    167.  
    168. D/MainActivity: ausgelogt und getrennt
     
Die Seite wird geladen...