android ftp service 自动启动失败,从Android模拟器中的本地FTP服务器下载时出现错误“ 227进入被动模式” /“连接被拒绝”...

我正在尝试使用FTPSClientAndroid模拟器中运行的Java从本地FileZilla服务器下载文件。

我已经编写了此帮助程序代码来下载一个文件:

public boolean downloadSingleFile(FTPSClient ftpClient,

String remoteFilePath, File downloadFile) {

OutputStream outputStream;

Log.i("t1", remoteFilePath + " - " + downloadFile.getAbsolutePath());

try {

outputStream = new BufferedOutputStream(new FileOutputStream(

downloadFile));

ftpClient.setFileType(FTP.BINARY_FILE_TYPE);

boolean retval = ftpClient.retrieveFile(remoteFilePath, outputStream);

outputStream.flush();

return retval;

} catch (Exception e) {

Log.e("dwFile", e.toString());

Log.e("dwFile", ftpClient.getReplyString());

} return false;

}

我这样称呼这个功能:

FTPSClient dwClient = new FTPSClient();

dwClient.addProtocolCommandListener(

new PrintCommandListener(

new PrintWriter(new OutputStreamWriter(System.out, "UTF-8")), true));

dwClient.setConnectTimeout(30 * 1000);

dwClient.connect(OmsSettingsFunctions.getFTPServer());

Log.i("dwDB", dwClient.getReplyString());

if (dwClient.login(FPTuser, FTPpass)) {

Log.i("dwDB", dwClient.getReplyString());

dwClient.enterLocalPassiveMode();

File dwFile = new File(externalPath + "/Android/data/com.myapp/files/Documents/db.temp");

if(!downloadSingleFile(dwClient, "/DBs/db.txt", dwFile)) {

Log.e("dwDB", "Download could not finish (DB)");

Log.e("dwDB", dwClient.getReplyString());

}...

但我不断收到此错误:

I/System.out: 220-FileZilla Server version 0.9.41 beta

I/System.out: 220-written by Tim Kosse (Tim.Kosse@gmx.de)

220 Please visit http://sourceforge.net/projects/filezilla/

I/System.out: AUTH TLS

D/EGL_emulation: eglMakeCurrent: 0xa209dd60: ver 3 0 (tinfo 0x9f652ff0)

D/EGL_emulation: eglMakeCurrent: 0xa209dd60: ver 3 0 (tinfo 0x9f652ff0)

I/System.out: 234 Using authentication type TLS

I/dwDB: 234 Using authentication type TLS

I/Permission: Readingpermission is granted

I/Permission: Writingpermission is granted

I/System.out: USER *******

I/System.out: 331 Password required for omstest

I/System.out: PASS *******

I/System.out: 230 Logged on

I/dwDB: 230 Logged on

I/t1: /DBs/db.txt - /storage/0FF0-280B/Android/data/com.myapp/files/Documents/db.temp

I/System.out: TYPE I

I/System.out: 200 Type set to I

I/System.out: PASV

I/System.out: 227 Entering Passive Mode (127,0,0,1,199,113)

E/dwFile: java.net.ConnectException: Connection refused

227 Entering Passive Mode (127,0,0,1,199,113)

E/dwDB: Download could not finish (DB)

227 Entering Passive Mode (127,0,0,1,199,113)

我已经尝试使用enterLocalActivemode()代替,enterLocalPassivmode()但没有帮助。FTP服务器是TLS强制的,并且在我的本地计算机上运行。我正在通过10.0.2.2(Android回送)连接到它。我怎样才能解决这个问题?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值