I am using Spring Integration to upload file on remote server. It works fine but logs an exception every time.

Config class

@Bean
fun sftpSessionFactory(): DefaultSftpSessionFactory {
    val factory = DefaultSftpSessionFactory(true)
    factory.setHost(sftpUrl)
    factory.setPort(sftpPort)
    factory.setUser(sftpUsername)
    factory.setPassword(sftpPassword)
    factory.setAllowUnknownKeys(true)
    return factory
}

@Bean
fun sftpRemoteFileTemplate(): SftpRemoteFileTemplate =
    SftpRemoteFileTemplate(sftpSessionFactory())

Service class

private fun uploadFile(file: File) =
    sftpRemoteFileTemplate.execute { session ->
        file.inputStream()
            .use {
                session.write(it, "path/to/directory/${file.name}")
            }
    }

Exception

INFO 505776 --- [isk.com session] com.jcraft.jsch : Caught an exception, leaving main loop due to Connection reset INFO 505776 --- [isk.com session] com.jcraft.jsch : Disconnecting from www.RemoteServer.com port 22

How to get rid of this?

0

There are 0 best solutions below