关于Honeycomb的JSch

时间:2012-01-01 20:50:30

标签: android ssh jsch

我正在开发一款使用sftp在手机和服务器之间传输文件的Android应用。目前我正在使用jsch(0.1.45)和spongycastle。一切正常,除了Honeycomb(在ICS上工作正常),我已经尝试了我能想到的一切。

连接和列出文件的行为符合预期,但当我尝试更改远程目录或传输文件时,我得到以下异常:

01-01 20:42:40.270: E/SFTP(362): Caused by: java.io.IOException: inputstream is closed
01-01 20:42:40.270: E/SFTP(362):    at com.jcraft.jsch.ChannelSftp.fill(ChannelSftp.java:2529)
01-01 20:42:40.270: E/SFTP(362):    at com.jcraft.jsch.ChannelSftp.header(ChannelSftp.java:2553)
01-01 20:42:40.270: E/SFTP(362):    at com.jcraft.jsch.ChannelSftp._realpath(ChannelSftp.java:2010)
01-01 20:42:40.270: E/SFTP(362):    at com.jcraft.jsch.ChannelSftp.cd(ChannelSftp.java:300)

如果我在调试模式下启动ssh服务器,我得到:

debug2: fd 3 setting TCP_NODELAY
debug3: packet_set_tos: set IP_TOS 0x08
debug2: fd 11 setting O_NONBLOCK
debug2: fd 10 setting O_NONBLOCK
debug2: fd 13 setting O_NONBLOCK
debug2: channel 0: read 641 from efd 13
debug3: channel 0: discard efd
Bad packet length 920403810.
Disconnecting: Packet corrupt

Jsch logger给了我以下内容:

01-01 20:46:12.301: D/LOG(362): Connecting to 192.168.2.100 port 22
01-01 20:46:12.371: D/LOG(362): Connection established
01-01 20:46:12.830: D/LOG(362): Remote version string: SSH-2.0-OpenSSH_5.8p1 Debian-7ubuntu1
01-01 20:46:12.830: D/LOG(362): Local version string: SSH-2.0-JSCH-0.1.45
01-01 20:46:12.830: D/LOG(362): CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
01-01 20:46:13.274: D/LOG(362): CheckKexes: diffie-hellman-group14-sha1
01-01 20:46:13.391: D/dalvikvm(362): GC_CONCURRENT freed 809K, 34% free 8829K/13319K, paused 6ms+7ms
01-01 20:46:14.164: D/LOG(362): SSH_MSG_KEXINIT sent
01-01 20:46:14.164: D/LOG(362): SSH_MSG_KEXINIT received
01-01 20:46:14.171: D/LOG(362): kex: server->client aes128-ctr hmac-md5 none
01-01 20:46:14.171: D/LOG(362): kex: client->server aes128-ctr hmac-md5 none
01-01 20:46:14.270: D/LOG(362): SSH_MSG_KEXDH_INIT sent
01-01 20:46:14.270: D/LOG(362): expecting SSH_MSG_KEXDH_REPLY
01-01 20:46:14.431: D/LOG(362): ssh_rsa_verify: signature true
01-01 20:46:14.441: D/LOG(362): Host '192.168.2.100' is known and mathces the RSA host key
01-01 20:46:14.441: D/LOG(362): SSH_MSG_NEWKEYS sent
01-01 20:46:14.441: D/LOG(362): SSH_MSG_NEWKEYS received
01-01 20:46:14.499: D/LOG(362): SSH_MSG_SERVICE_REQUEST sent
01-01 20:46:14.510: D/LOG(362): SSH_MSG_SERVICE_ACCEPT received
01-01 20:46:14.571: D/LOG(362): Authentications that can continue: publickey,keyboard-interactive,password
01-01 20:46:14.584: D/LOG(362): Next authentication method: publickey
01-01 20:46:14.591: D/LOG(362): Authentications that can continue: password
01-01 20:46:14.591: D/LOG(362): Next authentication method: password
01-01 20:46:14.711: D/LOG(362): Authentication succeeded (password).
01-01 20:46:18.512: D/LOG(362): Caught an exception, leaving main loop due to SSH_MSG_DISCONNECT: 2 Packet corrupt 
01-01 20:46:18.512: D/LOG(362): Disconnecting from 192.168.2.100 port 22

是否有人使用jsch蜂窝工作正常工作?

1 个答案:

答案 0 :(得分:1)

经过几天撞到这个,我终于发现了问题。当我将我的应用程序调整为蜂窝时,我使用AsyncTasks从UI线程中删除了所有网络调用。显然我忘了删除其中一个电话,而且Exception正在被忽视而滑落。奇怪的是,它正在与ICS合作。

显然,JSch和Honeycomb没有任何问题。只是一个沉睡的开发人员。现在一切正常。