android FTPClient cannot upload file - FTP response 421 received. Server closed connection -


i know there many similar questions asked before. looked of them , tried possible solutions including changed several ftp servers, still not solve problem. there no problem ftp command line though. turned off firewall. here code snippet:

        ftpclient.login(username, password);          int mode = ftpclient.getdataconnectionmode();         if(mode == ftpclient.passive_local_data_connection_mode)             ftpclient.enterlocalpassivemode();         else if(mode == ftpclient.active_local_data_connection_mode)             ftpclient.enterlocalactivemode();          ftpclient.setfiletype(ftp.binary_file_type, ftp.binary_file_type);         ftpclient.setfiletransfermode(ftp.binary_file_type);         //ftpclient.setpassivenatworkaround(false);          if(logd) log.d("before create out");         string out = ordertostring();         if(logd) log.d("out="+out);         inputstream stream = new bytearrayinputstream(out.getbytes("utf-8"));          if(logd) log.d("before upload orders.xml");         boolean res = ftpclient.storefile("orders.xml", stream);         if(!res) log.d("store file failed");         ftpclient.completependingcommand();         stream.close(); 

here logcat:

........................................

d/salesmanager( 408): before create out d/salesmanager( 408): out= d/salesmanager( 408): d/salesmanager( 408):
1 d/salesmanager( 408): 2013-10-06 12:07:39 d/salesmanager( 408): 1 d/salesmanager( 408): 617.25 d/salesmanager( 408): d/salesmanager( 408): d/salesmanager( 408): before upload orders.xml d/sntpclient( 60): request time failed: java.net.socketexception: address family not supported protocol w/system.err( 408): org.apache.commons.net.ftp.ftpconnectionclosedexception: ftp response 421 received. server closed connection. d/sntpclient( 60): request time failed: java.net.socketexception: address family not supported protocol mainactivity$loadasynctask.doinbackground(mainactivity.java:1) w/system.err( 408): @ android.os.asynctask$2.call(asynctask.java:185) w/system.err( 408):
@ java.util.concurrent.futuretask$sync. innerrun(futuretask.java:305) w/system.err( 408): @ java.util.concurrent.futuretask.run(futuretask.java: 137) w/system.err( 408): @ java.util.concurrent.threadpoolexecutor. runworker(threadpoolexecutor.java:1068) w/system.err( 408): @ java.util.concurrent.threadpoolexecutor$worker. run(threadpoolexecutor.java:561) w/system.err( 408): @ java.lang.thread.run(thread.java:1096)

.......................

edit ever made download text file never make uploading text file through. @ 1 time during testing ever made uploading text file half done -- empty same-name file created on server.

use ftp4j solved problem. several days wasted on commons.ftpclient


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -