I was working on a client application where I need to receive files from FTP server. The following are main points of this application
· Based on the history I figured out the maximum size of file could up to 5KB (not to big).
· A single host instance was created for the host specified as receive handler for FTP adapter.
Duplicate files were getting received with the following messages in event log.
Event Type: Warning
The adapter "FTP" raised an error message. Details "Unable to receive the file "<FileName>" from the FTP server. The error that occurred was "A stream read or write operation failed because the stream is in an error state. ". ".
Event Type: Error
There was a failure executing the receive pipeline: "Microsoft.BizTalk.DefaultPipelines.PassThruReceive, Microsoft.BizTalk.DefaultPipelines, Version=184.108.40.206, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Source: "Pipeline " Receive Port: "<ReceivePortName>" URI: "<URI>" Reason: Unable to receive the file "<FileName>" from the FTP server. The error that occurred was "A stream read or write operation failed because the stream is in an error state. ".
I noticed that this error is occurring only when the number of files are more than 120 i.e. when the connection need to be opened for some long time. After going through the FTP log it seems as connection was getting terminated before all the files get transferred.
After changing the Mode to ‘Passive’ the issue gets resolved.
One possible cause of it could be that the firewall is causing this error but I have not investigated the firewall settings yet.