FTP issues with FTP inbound adapter

In our project, we are using ftp: an inbound adapter channel to poll files from an FTP server. Works great. But it doesn't work between polls. When I see the logs of the FTP server, I see "425 Can not open a data connection." now when i restart or stop and restart ftp: inbound-adapter-it polls it correctly. This issue occurs repeatedly, in order to solve, I need to stop / start ftp: inbound-channel-adapter.ftp: inbound-channel-adapter is running in Linux operating system.

I am using spring-integration 3 so that I have included xsd info more clearly (spring-integration-3.0.xsd, spring-integration-ftp-3.0.xsd)

is there any specific client mode I need to set for FTP ie Active (local / remote) / Passive (local / remote) etc.? below is my ftp config: inbound adapter-pipe

<bean id="ftpClientFactory" class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
        <property name="host" value="abcd.com"/>
        <property name="port" value="21"/>
        <property name="username" value="userid"/>
        <property name="password" value="password"/>
    </bean>

<int-ftp:inbound-channel-adapter id="ftpInbound"
                channel="ftpChannel"
                session-factory="ftpClientFactory"
                auto-create-local-directory="true"
                delete-remote-files="true"
                remote-directory="/"  
                local-filename-generator-expression="new java.text.SimpleDateFormat('yyyy-MM-dd-hhmmssSSS').format(new java.util.Date()) + '.'+ #this"  
                local-directory="${ftp.sync.folder}"
                remote-file-separator="/">
    </int-ftp:inbound-channel-adapter>

      

so not sure if I can do something on the FTP server. But I like to see if there is any option in ftp: inbound adapter-pipe or whatever you suggest so that whenever the FTP server throws "425 Cannot open data connection." instead of manually stopping / starting ftp: inbound-adapter-is there any option or automatic way to make this work. thank

Added information about the version of the integration of spring and ftp session factory.

+3


source to share


1 answer


There are two ways to connect to active and passive FTP server mode.

ActiveMode: where the FTP server should make a data connection with the port specified by the client (firewall issues if the port is blocked by a fire wall and you get 425 Data connection error)

Passivemode: where the client should connect to the port mentioned by the FTP server. (There is no fairwall issue on the client side. Also we can configure passvieports on the FTP server and block those ports not through the FTP server firewall.)



If you didn't specify any client mode in ftpsessionfactory it defaults to active mode ie clientMode = 0. So I have a firewall issue causing 425 connectivity issue. After I disabled the firewall it worked well. So now I changed my FTPsessionfactory to use Passivemode, so the FTP server never cares about the clients. Firewall

<bean id="ftpClientFactory" class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
        <property name="host" value="abcd.com"/>
        <property name="port" value="21"/>
        <property name="username" value="userid"/>
        <property name="password" value="password"/>
<!-- 2  passive mode -->
<property name="clientMode" value="2"/>
</bean>

      

This method never cares about the client firewall. very good post about FTP http://slacksite.com/other/ftp.html

+1


source







All Articles