0
votes

I am trying to connect to an SFTP location and download a .zip file using Mule SFTP connector. It looks very straightforward configuration, but I am not sure what is missing in my configuration. I am not able to make out why it is not working for me. Can someone please look at it and suggest what should I change to make work?

In below flows configurations, I am starting with an HTTP end point (http://localhost:8181/invoice) then “ftpconnectivityFlow1” is called and it checks the value of "ftp" variable and based on its value it either goes to my FTP location or SFTP location. when I set the variable "ftp" to true it works as expected, as I can see file from FTP location is downloaded in my output folder and deleted from FTP location as expected. When I set it to false it is not giving any error but file at SFTP location is still there meaning it is not able to read file (I am guessing) and it is not downloaded to my output folder. So for some debugging I added a custom transformer so that I can inspect payload. In my custom transformer I notice that when it connects to FTP location it has some binary data (all number), I am guessing it is my .zip file, but when variable "ftp" is set to false, meaning it is trying to connect to SFTP location in that case payload contains "/invoice" which is my http relative path. So my output folder contains a file with name “null” and all it contains is "/invoice"

Any help is greatly appreciated.

<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>
1

1 Answers

0
votes
<ftp:inbound-endpoint host="host" port="22" ... doc:name="FTP"/>
...
 <sftp:inbound-endpoint ... port="21" user="user"/>

You might have those port numbers backwards. FTP normally runs on port 21 and SFTP (SSH) normally uses port 22.