I have a peculiar behavior with SFTP connector in MuleSoft. When a file is placed, I need to pick up and process the file in MuleSoft. Here in the first step, I'm fetching the file name by using the 'SFTP connector On New or Updated' which is auto triggered when a new file is placed. In the second step, I'm passing this file name to the 'SFTP Read' connector and fetching actual data.
When I manually pass file name to the 'SFTP Read' connector, I'm able to fetch the data without any issues, but I get below error when I try to fetch the file name using 'SFTP connector On New or Updated'.
FYI - I'm using similar connector configuration in both the scenarios
<sftp:config name="SFTP_Conf" doc:name="SFTP Config" doc:id="62dfd75b-941c-ec70c3bdf3" >
<sftp:connection host="${sftp.host}" port="${sftp.port}" username="${sftp.username}" password="${sftp.password}" identityFile="${sftp.identityFile}" passphrase="${sftp.passphrase}" workingDir="365_CRM">
<pooling-profile maxIdle="1" minEvictionMillis="60000" evictionCheckIntervalMillis="30000" />
<sftp:listener doc:name="On New or Updated File" doc:id="7b435458-a0c2-b1b5bda7b19" config-ref="SFTP_Conf" watermarkEnabled="true" outputMimeType="application/xlsx" outputEncoding="ISO-8859-1">
<scheduling-strategy >
<fixed-frequency />
</scheduling-strategy>
</sftp:listener>
</sftp:connection>
<expiration-policy />
</sftp:config>
Error:
Found exception trying to poll directory '/365_CRM'. Will try again on the next poll.
org.mule.runtime.api.exception.MuleRuntimeException: Found exception trying to obtain path /365_CRM/abc.xlsx
Caused by: org.mule.runtime.api.exception.MuleRuntimeException: Could not obtain attributes for path /365_CRM/abc.xlsx
Caused by: org.mule.extension.sftp.internal.exception.SftpConnectionException: Error occurred while trying to connect to host
Caused by: org.mule.runtime.extension.api.exception.ModuleException: org.mule.runtime.api.connection.ConnectionException: Channel is being closed
I have a peculiar behavior with SFTP connector in MuleSoft. When a file is placed, I need to pick up and process the file in MuleSoft. Here in the first step, I'm fetching the file name by using the 'SFTP connector On New or Updated' which is auto triggered when a new file is placed. In the second step, I'm passing this file name to the 'SFTP Read' connector and fetching actual data.
When I manually pass file name to the 'SFTP Read' connector, I'm able to fetch the data without any issues, but I get below error when I try to fetch the file name using 'SFTP connector On New or Updated'.
FYI - I'm using similar connector configuration in both the scenarios
<sftp:config name="SFTP_Conf" doc:name="SFTP Config" doc:id="62dfd75b-941c-ec70c3bdf3" >
<sftp:connection host="${sftp.host}" port="${sftp.port}" username="${sftp.username}" password="${sftp.password}" identityFile="${sftp.identityFile}" passphrase="${sftp.passphrase}" workingDir="365_CRM">
<pooling-profile maxIdle="1" minEvictionMillis="60000" evictionCheckIntervalMillis="30000" />
<sftp:listener doc:name="On New or Updated File" doc:id="7b435458-a0c2-b1b5bda7b19" config-ref="SFTP_Conf" watermarkEnabled="true" outputMimeType="application/xlsx" outputEncoding="ISO-8859-1">
<scheduling-strategy >
<fixed-frequency />
</scheduling-strategy>
</sftp:listener>
</sftp:connection>
<expiration-policy />
</sftp:config>
Error:
Found exception trying to poll directory '/365_CRM'. Will try again on the next poll.
org.mule.runtime.api.exception.MuleRuntimeException: Found exception trying to obtain path /365_CRM/abc.xlsx
Caused by: org.mule.runtime.api.exception.MuleRuntimeException: Could not obtain attributes for path /365_CRM/abc.xlsx
Caused by: org.mule.extension.sftp.internal.exception.SftpConnectionException: Error occurred while trying to connect to host
Caused by: org.mule.runtime.extension.api.exception.ModuleException: org.mule.runtime.api.connection.ConnectionException: Channel is being closed
The SFTP connection configuration in the question lacks a reconnection strategy. An connectivity error like the one shown could prevent it of further connectivity to the server. You should add one.
Example:
<sftp:config name="SFTP_Config" ... >
<sftp:connection ...>
<reconnection >
<reconnect-forever />
</reconnection>
<pooling-profile ... />
</sftp:connection>
</sftp:config>