Mule无法从SFTP位置下载文件
问题描述:
我想连接到SFTP位置并使用Mule SFTP连接器下载.zip文件。它看起来非常直接,但我不确定我的配置中缺少什么。我无法弄清楚为什么它不适合我。有人可以看看它,并建议我应该改变什么工作?Mule无法从SFTP位置下载文件
在下面的流程配置中,我从一个HTTP终点(http://localhost:8181/invoice)开始,然后调用“ftpconnectivityFlow1”并检查“ftp”变量的值,并根据它的值将它转到我的FTP位置或SFTP位置。当我将变量“ftp”设置为true时,它按预期工作,因为我可以看到来自FTP位置的文件已下载到我的输出文件夹中,并按预期从FTP位置删除。当我将它设置为false时,它不会给出任何错误,但是SFTP位置处的文件仍然存在,这意味着它不能读取文件(我猜测),并且它不会下载到我的输出文件夹中。所以对于一些调试,我添加了一个自定义转换器,以便我可以检查有效载荷。在我的自定义转换器中,我注意到当它连接到FTP位置时,它有一些二进制数据(所有数字),我猜它是我的.zip文件,但当变量“ftp”设置为false时,表示它试图连接在这种情况下,有效载荷包含“/ invoice”,这是我的http相对路径。所以我的输出文件夹包含一个名称为“null”的文件,它包含的所有文件是“/ invoice”
任何帮助,非常感谢。
<flow name="ftpconnectivityFlow1">
<logger message="ftp:#[message.outboundProperties['ftp']]" doc:name="Logger" level="INFO"/>
<choice doc:name="Choice">
<when expression="#[message.outboundProperties['ftp']==true]">
<flow-ref name="FTPConnection" doc:name="FTPFileDownloadConnection"/>
</when>
<otherwise>
<flow-ref name="SFTPConnection" doc:name="SFTPFileDownloadConnection"/>
</otherwise>
</choice>
</flow>
<flow name="FTPConnection">
<ftp:inbound-endpoint host="host" port="22" path="abc" user="user" password="password" responseTimeout="10000" doc:name="FTP"/>
<custom-transformer class="abc.transformer.CustomeFileTransformer" />
<logger message="connected to FTP" level="INFO" doc:name="Logger"/>
<file:outbound-endpoint path="output" outputPattern="#[message.inboundProperties['originalFilename']]" responseTimeout="10000" doc:name="File"/>
</flow>
<flow name="SFTPConnection">
<sftp:inbound-endpoint connector-ref="sftp-default" doc:name="SFTP" responseTimeout="10000" host="host" password="password" path="/Inbound" port="21" user="user"/>
<custom-transformer class="abc.transformer.CustomeFileTransformer" />
<logger level="INFO" doc:name="Logger"/>
<file:outbound-endpoint path="output" outputPattern="#[message.inboundProperties['originalFilename']]" responseTimeout="10000" doc:name="File"/>
</flow>
答
<ftp:inbound-endpoint host="host" port="22" ... doc:name="FTP"/>
...
<sftp:inbound-endpoint ... port="21" user="user"/>
你可能有这些端口号倒退。 FTP通常在端口21上运行,SFTP(SSH)通常使用端口22.
感谢您的输入,仔细检查后发现问题是密码中的端口和特殊字符的组合,我仍然不确定为什么我不是获取错误消息。但最后我的问题解决了。 – Rai