java 通过 JSch 的 SFTP 抛出错误 4:失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26903923/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 10:50:51  来源:igfitidea点击:

SFTP via JSch is throwing error 4: Failure

javasftpjschwinscp

提问by Saikat

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

我在尝试将文件从 Windows 用 SFTP 传输到 Unix 服务器时遇到了一个奇怪的问题。错误“堆栈跟踪”是 -

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.

我在其他论坛上搜索了很多,但无法找到根本原因。我还观察到一件事 - 我正在尝试 SFTP 的文件名是 *.xml,当我将其更改为 *.XML 时,SFTP 是“成功的”。很奇怪无法确定问题。我正在尝试使用 JSch Java API。但是我在尝试 WinSCP 前端时遇到了同样的问题。

采纳答案by Martin Prikryl

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

由于许多不同的原因,OpenSSH SFTP 服务器返回代码 4(失败)很常见的,但没有提供任何详细信息

You would have to check SFTP server logto find more.

您必须检查SFTP 服务器日志才能找到更多信息。

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.

尽管最常见的原因是缺少可用磁盘或用户配额空间——这通常可以通过创建的文件大小为零来识别。

回答by Bilal Ahmed Yaseen

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.

我面临同样的问题。请确保您的 SFTP 服务正在运行。如果它已经在运行,那么重新启动这个服务应该可以解决问题。

回答by ashutosh singh

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

命令:df 文件夹的路径

回答by MikeKulls

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.

我遇到过同样的问题。尝试了一切,结果我将超时设置为我认为是 30 秒,但实际上是 30 毫秒。将其更改为 30000ms 解决了该问题。

session.setTimeout(30000);