4
votes

Our project we are using ftp:inbound-channel-adapter to poll files from the FTP server.it working fine.But in between the polling is not working.when i see the FTP server logs i see "425 Can't open data connection." now when i restart or stop and start the ftp:inbound-channel-adapter again its polling properly.This issue is repeatedly occurring to solve i need to stop/start the ftp:inbound-channel-adapter.ftp:inbound-channel-adapter is running in linux OS.

Am using spring-integration 3 just to more clear i have included the xsd info (spring-integration-3.0.xsd,spring-integration-ftp-3.0.xsd)

is there any specific client mode i need to set for FTP i.e Active(local/remote) /Passive(local/remote) etc? below my ftp:inbound-channel-adapter configuration

<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 i can do something in the FTP server.but i like to see is there any option in ftp:inbound-channel-adapter or any thing you guy suggest so that whenever FTP server throws "425 Can't open data connection." instead of manually stop/start the ftp:inbound-channel-adapter is there any option or automatic way to make this work.Thanks

Added info on spring integration version and ftp session factory.

1
Please show your Spring Integration version and add your session factory configuration to the question.Gary Russell

1 Answers

2
votes

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

ActiveMode : where FTP server has to made Data Connection with the port mentioned by the Client (firewall issues if port is blocked by fire wall and you will get 425 Data Connection error)

Passivemode : Where client has to made Data connection with the port mentioned by the FTP server. (no fairwall issues in the client side.Also we can configure the passvieports in FTP server and made these ports not block by FTP servers firewall.)

If you not specify any clientmode in ftpsessionfactory it defaults to the Active mode i.e clientMode=0. So i have firewall issue which causes 425 data connection issue.After i OFF the firewall its worked well.So now i changed my FTPsessionfactory to use Passivemode so FTP server never cares about 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 way never cares about client's firewall. very good post about FTP http://slacksite.com/other/ftp.html