如何使用WSO2 VFS实现服务器间文件传输?配置异常求助
WSO2 EI 文件传输服务部署后无日志但传输失败问题
问题背景
已在Integration Studio中通过Proxy和Sequence搭建WSO2文件传输服务,本地文件夹间传输功能正常;将Carbon应用导出部署到Enterprise Integrator后,无论是服务器间还是同一服务器内的文件夹传输,均无错误日志输出,但文件始终未完成传输。使用IIS搭建自有FTP服务器,且已对FTP路径进行编码处理。
配置代码
Proxy Service 配置
<?xml version="1.0" encoding="UTF-8"?> <proxy name="YenloProxy" startOnLoad="true" transports="http https" xmlns="http://ws.apache.org/ns/synapse"> <target> <inSequence> <log level="custom"> <property name="sequence" value="Proxy"/> </log> <clone> <target sequence="YenloSequence"/> </clone> </inSequence> <outSequence/> <faultSequence/> </target> <parameter name="transport.PollInterval">15</parameter> <parameter name="transport.vfs.FileURI">vfs:ftp://ftp-user%3AP%40ssw0rd01%40192.168.1.36%3A21%2FIncoming%2F</parameter> <parameter name="transport.vfs.ContentType">text/plain</parameter> <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter> <parameter name="transport.vfs.MoveAfterFailure">vfs:ftp://ftp-user%3AP%40ssw0rd01%40192.168.1.36%3A21%2FFailure%2F</parameter> <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter> <parameter name="transport.vfs.FileNamePattern">.*.dat</parameter> <parameter name="transport.vfs.MoveAfterProcess">vfs:ftp://ftp-user%3AP%40ssw0rd01%40192.168.1.36%3A21%2FOutgoing%2F</parameter> </proxy>
Sequence 配置
<?xml version="1.0" encoding="UTF-8"?> <sequence name="YenloSequence" trace="disable" xmlns="http://ws.apache.org/ns/synapse"> <log level="custom"> <property name="sequence" value="YenloSequence"/> </log> <property expression="fn:concat(fn:substring-after(get-property('MessageID'), 'urn:uuid:'), '.txt')" name="transport.vfs.ReplyFileName" scope="transport" type="STRING"/> <property name="OUT_ONLY" scope="default" type="STRING" value="true"/> <property name="ClientApiNonBlocking" scope="axis2" type="STRING" value="true"/> <send> <endpoint name="FileEpr"> <address uri="vfs:ftp://ftp-user%3AP%40ssw0rd01%40192.168.1.36%3A21%2FOutput%2F"> <suspendOnFailure> <initialDuration>-1</initialDuration> <progressionFactor>1</progressionFactor> </suspendOnFailure> <markForSuspension> <retriesBeforeSuspension>0</retriesBeforeSuspension> </markForSuspension> </address> </endpoint> </send> </sequence>
排查与解决方案
- 修正Proxy传输协议配置:当前Proxy的
transports属性仅包含http https,但VFS轮询依赖vfs传输协议,需修改为transports="vfs http https",否则Proxy无法触发VFS的文件轮询逻辑。 - 验证FTP连接可用性:在EI服务器上使用命令行工具(如
ftp或curl)测试目标FTP服务器的连接,确认用户名、密码、端口及目录路径可正常访问,排除防火墙或网络策略的阻断影响。 - 调整FTP路径编码方式:尝试使用未编码的密码格式(如
vfs:ftp://ftp-user:P@ssw0rd01@192.168.1.36:21/Incoming/)测试,部分环境对编码后的URL解析可能存在兼容问题。 - 开启详细VFS日志:在EI的
log4j2.properties配置文件中,将org.apache.synapse.transport.vfs的日志级别设为DEBUG,查看是否有隐藏的连接错误或文件处理异常信息。 - 检查文件处理逻辑冲突:Proxy配置中设置了
ActionAfterProcess=MOVE到Outgoing目录,同时Sequence又将文件发送到Output目录,可能导致文件被移动后Sequence无法读取完整内容。可暂时注释Proxy的MoveAfterProcess配置,测试Sequence传输是否正常,再调整逻辑避免冲突。 - 校验IIS FTP配置:确认IIS FTP的被动模式端口范围已配置且防火墙开放对应端口;检查
ftp-user对Incoming、Outgoing、Failure、Output目录是否拥有读、写、修改权限。
内容的提问来源于stack exchange,提问作者Kelisha Govender
相关产品推荐
相关产品推荐

