0
votes

Hi i am integrating the SFTP (Version 5.1.6)into my spring boot application. Below is the configuration i am using . But sometime i am getting below exception and failing the transfer, not sure what is the issue how i can make sure there is no exception occurs.

Failed to write to 'TestFile.xml.writing' while uploading the file; nested exception is org.springframework.core.NestedIOException: failed to write file; nested exception is 4: java.io.IOException: Pipe closed

@Bean
public SessionFactory<ChannelSftp.LsEntry> sftpSessionFactory() {
    LOGGER.debug(" Creating SFTP Session Factory -Start");
    DefaultSftpSessionFactory factory = new DefaultSftpSessionFactory(true);
    factory.setHost(sftpHost);
    factory.setPort(sftpPort);
    factory.setUser(sftpUser);
    factory.setPassword(sftpPasword);
    factory.setAllowUnknownKeys(true);
    LOGGER.debug(" Creating SFTP Session Factory -End");
    return new CachingSessionFactory<>(factory);
}

 @Bean
@ServiceActivator(inputChannel = "toSftpChannel")
public MessageHandler handler() {
    SftpMessageHandler handler = new SftpMessageHandler(sftpSessionFactory());
    LOGGER.debug(" Creating SFTP MessageHandler - Start ");

    handler.setRemoteDirectoryExpression(new LiteralExpression(sftpRemoteDirectory));
    handler.setFileNameGenerator(new FileNameGenerator() {
        @Override
        public String generateFileName(Message<?> message) {
            if (message.getPayload() instanceof File) {

                return ((File) message.getPayload()).getName();
            } else {
                throw new IllegalArgumentException("Expected Input is File.");
            }
        }
    });
    LOGGER.debug(" Creating SFTP MessageHandler - End ");
    return handler;
}

@MessagingGateway
public interface UploadGateway {
    @Gateway(requestChannel = "toSftpChannel")
    void sendToSftp(File file);
    }
1

1 Answers

1
votes

Pipe closed

Simply means there was a network glitch or the server closed the connection for some reason; you will need to look at the server logs for more information.

You can add a retry advice to the outbound adapter to retry failures.