4
votes

I am using jsch to connect to a sftp server and download files.

My file size is 4.4MB.

The error is received message is too long.

What is the max limit of file size that can be downloaded?

Is there any config to change the max size limit?

heres how i connect session = jsch.getSession("##", "##", 22); session.setPassword("##"); session.setConfig("StrictHostKeyChecking", "no"); session.connect(); sftpChannel = (ChannelSftp)session.openChannel("sftp"); sftpChannel.connect(); sftpChannel.cd("##"); sftpChannel.lcd("##");

and the error message is

Error when fetching server responses from SFTP server. at com.scheduler.DataDiaryDataPullJob.main(DataDiaryDataPullJob.java:60) [classes/:na] Caused by: com.jcraft.jsch.JSchException: 4: Received message is too long: 1416128878 at com.jcraft.jsch.ChannelSftp.start(ChannelSftp.java:315) ~[jsch-0.1.50.jar:na] at com.jcraft.jsch.Channel.connect(Channel.java:152) ~[jsch-0.1.50.jar:na] at com.jcraft.jsch.Channel.connect(Channel.java:145) ~[jsch-0.1.50.jar:na] at com.scheduler.DataDiaryDataPullJob.downloadSurveyFiles(DataDiaryDataPullJob.java:152) [classes/:na] ... 2 common frames omitted Caused by: com.jcraft.jsch.SftpException: Received message is too long: 1416128878 at com.jcraft.jsch.ChannelSftp.start(ChannelSftp.java:265) ~[jsch-0.1.50.jar:na] ... 5 common frames omitted

Thanks, Sunil

2
can you provide more details? e.g. quoute the complete error message. and how do you connect/download?Florian
here is how i connectsunil
Interesting analysis: 1416128878 (decimal) = 5468696E (hexadecimal) = Thin (text ASCII) When you connect directly with a terminal $ ssh ... do you get a response containing "Thin"? stackoverflow.com/a/38897574/3301492Boris

2 Answers

3
votes

I just encountered this issue also and discovered my shell startup scripts were corrupting my sftp session.

From http://www.snailbook.com/faq/sftp-corruption.auto.html

"In order for this to work, the SSH session must be "clean" — that is, it must have on it only information transmitted by the programs at either end. What often happens, though, is that there are statements in either the system or per-user shell startup files on the server (.bashrc, .profile, /etc/csh.cshrc, .login, etc.) which output text messages on login, intended to be read by humans (like fortune, echo "Hi there!", etc.). Such code should only produce output on interactive logins, when there is a tty attached to standard input. If it does not make this test, it will insert these text messages where they don't belong: in this case, polluting the protocol stream between scp2/sftp and sftp-server. The first four bytes of the text gets interpreted as a 32-bit packet length, which will usually be a wildly large number, provoking the error message above."

One possible solution would be editing your startup scripts.

-1
votes

During log-in into the machine, it returns some texts. If those returned strings are more sftp will give error.

Try to reset your profile file (.bashrc or .cshrc) or comment all the echo's from profile file.

For me it worked.