1
votes

What can I tweak to solve this maximum connection problem? Any ways to specify a limit? This is from a Spring Integration application.

 <int-ftp:outbound-channel-adapter id="matasLiveProdSdkOutbound"
                                      channel="ftpOutboundChannel"
                                      session-factory="ftpsSessionFactory"
                                      charset="UTF-8"
                                      auto-create-directory="true"
                                      use-temporary-file-name="false"
                                      remote-file-separator="/"
                                      remote-directory-expression="${egnyte.remote.dir}"
                                      mode="IGNORE">
</int-ftp:outbound-channel-adapter>

This is the error I get:

Caused by: org.springframework.messaging.MessagingException: Failed to execute on session; nested exception is java.lang.IllegalStateException: failed to create FTPClient
    at org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:343)
    at org.springframework.integration.ftp.session.FtpRemoteFileTemplate.doExecuteWithClient(FtpRemoteFileTemplate.java:51)
    at org.springframework.integration.ftp.session.FtpRemoteFileTemplate.executeWithClient(FtpRemoteFileTemplate.java:47)
    at org.springframework.integration.ftp.session.FtpRemoteFileTemplate.exists(FtpRemoteFileTemplate.java:62)
    at org.springframework.integration.file.remote.RemoteFileTemplate.sendFileToRemoteDirectory(RemoteFileTemplate.java:435)
    ... 70 more
Caused by: java.lang.IllegalStateException: failed to create FTPClient
    at org.springframework.integration.ftp.session.AbstractFtpSessionFactory.getSession(AbstractFtpSessionFactory.java:171)
    at org.springframework.integration.ftp.session.AbstractFtpSessionFactory.getSession(AbstractFtpSessionFactory.java:41)
    at org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:332)
    ... 74 more
Caused by: javax.net.ssl.SSLException: 550 Cannot connect. You have reached maximum allowed simultaneous connections 7 per user.

Edit: Adding a CachingSessionFactory, like Gary advised me to...

@Bean
    public CachingSessionFactory ftpsCachingSessionFactory(DefaultFtpsSessionFactory ftpsSessionFactory) {
        CachingSessionFactory cachingSessionFactory = new CachingSessionFactory(ftpsSessionFactory, 5);
        cachingSessionFactory.setSessionWaitTimeout(1000);
        return cachingSessionFactory;
    }

I've wrapped the ftps session factory in a cachingSessionFactoy. Now, when I refer to this bean from the ftp outbound adapter above, I get an error telling me that the bean must be of type AbstractFtpSessionFactory. Is using an FTPS caching session factory not possible in an FTP outbound adapter - like the one above? I can't find any int-ftps namespace to switch the adapter with. The spring-integration-ftp-4.1xsd expectedly states that only a org.springframework.integration.ftp.session.DefaultFtpSessionFactory is accepted.

1

1 Answers

1
votes

Wrap the session factory in a CachingSessionFactory. Use this constructor which allows you to limit the number of sessions.

Also see setSessionWaitTimeout.