java - "Received message is too long" when connecting to SFTP server with JSch -


i wanted download files using ftp server. can through command-line , want same thing using java. code

session = jsch.getsession(user, server, 22); session.setpassword(pass); session.settimeout(10000); java.util.properties config = new java.util.properties(); config.put("stricthostkeychecking", "no"); session.setconfig(config); session.connect(); channelsftp channel = (channelsftp) session.openchannel("sftp"); **channel.connect();** channel.disconnect(); session.disconnect(); 

problem when channel connecting i.e channel.connect , getting error:

com.jcraft.jsch.jschexception: 4: received message long: 1619214428     @ com.jcraft.jsch.channelsftp.start(channelsftp.java:242)     @ com.jcraft.jsch.channel.connect(channel.java:200)     @ com.jcraft.jsch.channel.connect(channel.java:144)     @ com.cca.processor.ftpprocessor.main(ftpprocessor.java:54) caused by: 4: received message long: 1619214428     @ com.jcraft.jsch.channelsftp.start(channelsftp.java:214)     ... 3 more 

as commented yourself, cannot connect sftp client.

so there's nothing wrong jsch/java code.


the error occurs after ssh authentication, when sftp session starting.

it's typically caused startup shell script printing message, , breaking sftp protocol.

the number in error (1619214428) first 4 characters in message interpreted 32-bit number.

but in case not seem readable text (were it, winscp display readable form too). number stands ‭6083405c‬ in hexadecimal notation, <.(@ (where dot stands character outside of ascii table).

see winscp documentation error message:
https://winscp.net/eng/docs/message_large_packet


still, it's server broken, not code. should contact server administrator or review startup shell scripts of account.


though claim able use ftp command-line , winscp. maybe should use ftp (or better ftps), not sftp. cannot use jsch ftp (or ftps). can use apache commons ftpclient example.


Comments

Popular posts from this blog

PHP change url style -

renaming files in a directory using python or R -

ruby on rails - Carrierwave Timeout -