弹簧集成 - "管道关闭" SFTP出站通道适配器的异常

时间:2014-10-16 20:00:56

标签: sftp spring-integration connection-timeout

我正在使用带有SFTP出站通道适配器组件的spring-integration 2.1将文件传输到远程位置。 间歇性地,我得到以下异常:

Error handling message for file <file_name>  _org.springframework.integration.MessageDeliveryException: Error handling message for file <file_name>
... stack was trimmed to be contained in a single post...
Caused by: org.springframework.integration.MessagingException: Failed to write to '<file_name>.writing' while uploading the file
      at org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.sendFileToRemoteDirectory(FileTransferringMessageHandler.java:227)
      at org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.handleMessageInternal(FileTransferringMessageHandler.java:136)
      ... 225 more
Caused by: org.springframework.core.NestedIOException: failed to write file; nested exception is 4: java.io.IOException: Pipe closed
      at org.springframework.integration.sftp.session.SftpSession.write(SftpSession.java:109)
      at org.springframework.integration.file.remote.session.CachingSessionFactory$CachedSession.write(CachingSessionFactory.java:147)
      at org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.sendFileToRemoteDirectory(FileTransferringMessageHandler.java:222)
      ... 226 more
Caused by: 4: java.io.IOException: Pipe closed
      at com.jcraft.jsch.ChannelSftp._put(ChannelSftp.java:623)
      at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:480)
      at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:439)
      at org.springframework.integration.sftp.session.SftpSession.write(SftpSession.java:106)
      ... 228 more
Caused by: java.io.IOException: Pipe closed
      at java.io.PipedInputStream.read(PipedInputStream.java:291)
      at com.jcraft.jsch.Channel$MyPipedInputStream.updateReadSide(Channel.java:397)
      at com.jcraft.jsch.ChannelSftp._put(ChannelSftp.java:493)
      ... 231 more

我看过有关此类错误的帖子,但没有任何答案。

我认为SFTP服务器由于不活动(基本超时)而终止连接,但为什么Spring Integration不尝试建立新连接?

2 个答案:

答案 0 :(得分:0)

我建议你升级到更新版本的Spring Integration;当前版本是4.0.4。

或者您可以简单地禁用会话缓存。

我们几年前重写了会话缓存(在2.2;当前版本2.2.6),现在它检查从缓存中检索缓存会话时的陈旧会话。

cache-sessions属性不再可用;您必须将会话工厂包装在CachingSessionFactory中以立即缓存会话。

答案 1 :(得分:0)

重新启动执行jsch的Java服务解决了我的问题。

在我的情况下,服务器的主机ssh密钥发生了变化,例如,Azure VM上的一个奇怪策略会强制定期更新密钥。

相关问题