SFTP via JSch is throwing error 4: Failure
Asked Answered
R

5

18

I am facing a peculiar issue while trying to SFTP a file from Windows to Unix server. The error "stack trace" is -

4: Failure
    at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2846)
    at com.jcraft.jsch.ChannelSftp.checkStatus(ChannelSftp.java:2459)
    at com.jcraft.jsch.ChannelSftp._sendCLOSE(ChannelSftp.java:2465)
    at com.jcraft.jsch.ChannelSftp._put(ChannelSftp.java:683)
    at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:475)
    at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:365)

I have searched a lot on other forums but could not get to the root cause. I have observed one more thing - the file name, I am trying to SFTP, is *.xml when I change it to *.XML the SFTP is "successful". Very weird could not identify the issue. I am trying this using JSch Java API. But I have seen the same issue while trying the WinSCP front end.

Renegado answered 13/11, 2014 at 7:57 Comment(0)
H
21

It is common for OpenSSH SFTP server to return code 4 (Failure) for many different reasons, without giving any details.

You would have to check SFTP server log to find more.

Though the most usual cause is a lack of free disk or user quota space – Which can usually be identified by the file being created with zero size.

Hindemith answered 13/11, 2014 at 8:28 Comment(1)
In my case, the destination path was invalid: channelSftp.put(new ByteArrayInputStream("Hello World!".getBytes()),"/Bad/path/hello.txt");Engen
N
4

i was facing the same issue. was puzzled then i realized there was a space issue on the server folder. Please do check the server available space.

command: df path to the folder

Necrotomy answered 4/5, 2020 at 13:32 Comment(1)
Same with me, it was a space issue problemMarinara
O
2

I was facing the same issue. Please make sure that your SFTP service is running. And If it is already running then restarting this service should do the trick.

Overdue answered 9/6, 2017 at 6:48 Comment(0)
A
0

I had the same issue. Tried everything, turns out I had set the timeout to what I thought was 30s but it was actually 30ms. Changing it to 30000ms solved the issue.

session.setTimeout(30000);
Abacist answered 27/6, 2019 at 5:2 Comment(0)
J
0

I've seen this error and the cause in my case was, the uploaded file names weren't supported by the file system used by the SFTP server.

Jerk answered 21/10, 2020 at 14:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.