我收到以下错误:
java.net.ConnectException:无法连接到/139.59.67.108(端口21):连接失败:ECONNREFUSED(拒绝连接)
引起:android.system.ErrnoException:连接失败:ECONNREFUSED(拒绝连接) 在libcore.io.Posix.connect(本机方法)
这是我的代码
try
{
FTPClient con = null;
con = new FTPClient();
con.connect("139.59.67.108");
Log.v("checkLogin", "succeeded");
if (con.login("xxxx", "xxxx"))
{
con.enterLocalPassiveMode(); // important!
con.setFileType(FTP.BINARY_FILE_TYPE);
///data/data/com.prd.inspirationslate/databases
String data = "/data/data/com.prd.inspirationslate/databases"; //path on device
FileInputStream in = new FileInputStream(new File(data));
Log.v("upload result check", "succeeded");
boolean result = con.storeFile("/vivekm4a.m4a", in);
in.close();
if (result) Log.v("upload result", "succeeded");
con.logout();
con.disconnect();
}
}
catch (Exception e)
{
e.printStackTrace();
}
尝试通过服务器上的ftp上传文件。在filezilla上我可以轻松连接
记录跟踪
java.net.ConnectException:无法连接到/139.59.67.108(端口21):连接失败:ECONNREFUSED(连接被拒绝) W / System.err:at libcore.io.IoBridge.connect(IoBridge.java:124) W / System.err:at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183) W / System.err:at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:163) W / System.err:at java.net.Socket.startupSocket(Socket.java:592) W / System.err:at java.net.Socket.tryAllAddresses(Socket.java:128) W / System.err:在java.net.Socket。(Socket.java:178) W / System.err:在java.net.Socket。(Socket.java:150) W / System.err:at org.apache.commons.net.DefaultSocketFactory.createSocket(DefaultSocketFactory.java:53) W / System.err:at org.apache.commons.net.SocketClient.connect(SocketClient.java:162) W / System.err:at org.apache.commons.net.SocketClient.connect(SocketClient.java:250) W / System.err:at com.prd.inspirationslate.LoginActivity $ 2 $ 1.run(LoginActivity.java:120) W / System.err:at java.lang.Thread.run(Thread.java:818) W / System.err:引起:android.system.ErrnoException:connect 失败:ECONNREFUSED(连接被拒绝)W / System.err:at libcore.io.Posix.connect(Native Method)W / System.err:at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:111)W / System.err: 在libcore.io.IoBridge.connectErrno(IoBridge.java:137)W / System.err: 在libcore.io.IoBridge.connect(IoBridge.java:122)W / System.err:... 另外11个