【问题标题】:SFTP Oubound Gateway Error - File List CommandSFTP 出站网关错误 - 文件列表命令
【发布时间】:2021-01-29 08:26:18
【问题描述】:

我有一个具有这种目录结构的 sftp 服务器:

main
--directoryA
  --subDirectory1
--directoryB
  --subDirectory1

但是当我尝试使用 sftp 出站网关获取目录列表时,我收到了这个错误:

Caused by: com.jcraft.jsch.SftpException: main/directoryA/directoryA/subDirectory1
at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2873) ~[jsch-0.1.55.jar:na]
at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:2225) ~[jsch-0.1.55.jar:na]
at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:2242) ~[jsch-0.1.55.jar:na]
at com.jcraft.jsch.ChannelSftp.ls(ChannelSftp.java:1592) ~[jsch-0.1.55.jar:na]
at com.jcraft.jsch.ChannelSftp.ls(ChannelSftp.java:1553) ~[jsch-0.1.55.jar:na]
at org.springframework.integration.sftp.session.SftpSession.list(SftpSession.java:111) ~[spring-integration-sftp-5.3.3.RELEASE.jar:5.3.3.RELEASE]
... 47 common frames omitted

我不确定为什么 directoryA 会追加两次。这是我的出站网关:

<int-sftp:outbound-gateway id="gateway"
  expression="payload"
  request-channel="request"
  remote-directory="main"
  command-options="-dirs -R"
  command="ls"
  session-factory="sessionFactory"
  reply-channel="reply">
</int-sftp:outbound-gateway>

【问题讨论】:

  • 您是否尝试过例如。没有递归列表?或提供具有绝对路径的目录,如“/main”
  • 是的,没有递归它只返回主目录上的文件。我还需要检查所有子目录路径。我还尝试给出该​​绝对路径“/main”。仍然出现此错误。
  • 你发送到这个网关的消息的负载是什么?

标签: spring spring-integration sftp


【解决方案1】:

查看服务器日志,看看是否有任何线索。

也许您没有访问该子目录的权限?

if(type!=SSH_FXP_ATTRS){
    if(type==SSH_FXP_STATUS){
      int i=buf.getInt();
      throwStatusError(buf, i);
    }

根据堆栈跟踪,服务器返回 101(客户端期望 105)。

值 (i) 未出现在堆栈跟踪中显示的 SftpException.getMessage() 中。

您可以通过遍历cause() 链并使用toString() 来查看它。

public class SftpException extends Exception{
  //private static final long serialVersionUID=-5616888495583253811L;
  public int id;
  private Throwable cause=null;
  public SftpException (int id, String message) {
    super(message);
    this.id=id;
  }
  public SftpException (int id, String message, Throwable e) {
    super(message);
    this.id=id;
    this.cause=e;
  }
  public String toString(){
    return id+": "+getMessage();
  }
  public Throwable getCause(){
    return this.cause;
  }
}

它可能会提供更多线索。

【讨论】:

  • 嗨,加里。实际上那个子目录(main/directoryA/directoryA/subDirectory1)不存在。这就是为什么它给了我那个错误响应。我的问题是为什么它在路径上双重附加 /directoryA 。我还在想办法。
  • 谢谢加里!你有暂定的 v.5.5 发布日期吗?
  • 5.5 直到今年夏末/初秋才会推出;但该修复已应用于 5.3 和 5.4 分支,因此您可以使用最新快照 (https://repo.spring.io/snapshot) spring.io/projects/spring-integration#learn 进行测试。此处列出了这些版本github.com/spring-projects/spring-integration/milestones 下一个 5.3 和 5.4 版本尚未安排,但可能会在 3 月中旬发布。如果您需要在此之前发布生产就绪版本,您应该对此问题发表评论,以便团队可以考虑何时安排它们。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-30
  • 1970-01-01
相关资源
最近更新 更多