Reputation: 1300
I'm developing an Android app that uses sftp to transfer files between the phone and a server. Currently I'm using jsch (0.1.45) and spongycastle. Everything is working correctly except on Honeycomb (works fine on ICS) and I already tried everything I could think of.
Connecting and listing files are behaving as expected but when I try to change the remote directory or transfer a file I get the following exception:
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)
If I start the ssh server in debug mode I get:
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 gives me the following:
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
Did anyone get sftp with jsch on honeycomb working correctly?
Upvotes: 0
Views: 639
Reputation: 1300
After some days banging my head against this one I finally found out the problem. When I adapted my app to honeycomb I removed all network calls from the UI thread using AsyncTasks. Apparently I forgot to remove one of those calls and the Exception was slipping by unnoticed. The strange thing is that it was working with ICS.
Apparently there isn't any problem with JSch and Honeycomb. Just a sleepy developer. Everything is working ok now.
Upvotes: 1