本文介绍了FTP 入站通道适配器的 FTP 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的项目我们正在使用 ftp:inbound-channel-adapter 从 FTP 服务器轮询文件.它工作正常.但在轮询之间无法正常工作.当我看到 FTP 服务器日志时,我看到425 Can't打开数据连接."现在,当我重新启动或停止并再次启动 ftp:inbound-channel-adapter 时,其轮询正常.此问题反复发生以解决我需要停止/启动 ftp:inbound-channel-adapter.ftp:inbound-channel-adapter在 linux 操作系统中运行.

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.

我使用 spring-integration 3 只是为了更清楚我已经包含了 xsd 信息(spring-integration-3.0.xsd,spring-integration-ftp-3.0.xsd)

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)

是否需要为 FTP 设置任何特定的客户端模式,即主动(本地/远程)/被动(本地/远程)等?在我的 ftp:inbound-channel-adapter 配置下方

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>

所以不确定我可以在 FTP 服务器上做些什么.但我想看看 ftp:inbound-channel-adapter 中是否有任何选项或您建议的任何内容,以便每当 FTP 服务器抛出425 无法打开"数据连接."而不是手动停止/启动 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

添加了有关 spring 集成版本和 ftp 会话工厂的信息.

Added info on spring integration version and ftp session factory.

推荐答案

有主动和被动两种方式连接到FTP服务器.

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

ActiveMode : FTP 服务器必须与客户端提到的端口建立数据连接(防火墙问题,如果端口被防火墙阻止,你会得到 425 数据连接错误)

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 : 客户端必须与 FTP 服务器提到的端口建立数据连接.(客户端没有fairwall问题.我们也可以在FTP服务器中配置passvieports,使这些端口不被FTP服务器防火墙阻止.)

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.)

如果您没有在 ftpsessionfactory 中指定任何 clientmode,它默认为 Active 模式,即 clientMode=0.所以我有防火墙问题,导致 425 数据连接问题.关闭防火墙后,它运行良好.所以现在我将 FTPsessionfactory 更改为使用 Passivemode,因此 FTP 服务器从不关心客户端防火墙

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>

这种方式从不关心客户端的防火墙.关于 FTP 的非常好的帖子 http://slacksite.com/other/ftp.html

This way never cares about client's firewall.very good post about FTP http://slacksite.com/other/ftp.html

这篇关于FTP 入站通道适配器的 FTP 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 01:55