Monday, July 4, 2011

FTP adapter issue: Unable to receive the file ""


Moving the original post
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.

Problem:
Duplicate files were getting received with the following messages in event log.

Event Type:     Warning
Description:
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
Description:
There was a failure executing the receive pipeline: "Microsoft.BizTalk.DefaultPipelines.PassThruReceive, Microsoft.BizTalk.DefaultPipelines, Version=3.0.1.0, 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. ".

FTP modes
You can use FTP in one of two ways: passive or active.
In active mode FTP client connect to a remote FTP server and requests information or a file, the FTP server makes a new connection back to the client to transfer the requested data. The FTP client chooses a random port to receive the data connection on. The client sends the port number it chose to the FTP server and then listens for an incoming connection on that port. The FTP server then initiates a connection to the client's address at the chosen port and transfers the data.
In passive mode the FTP client requests that the server pick a random port to listen on for the data connection. The server informs the client of the port it has chosen, and the client connects to this port to transfer the data.
Cause
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 confirming from the networking team I came to know that the firewall block the incoming connection.
Resolution
After changing the Mode to ‘Passive’ in the FTP adapter the issue gets resolved.

Cheers
Rohit Sharma

3 comments:

Anonymous said...

Thank's a lot for this useful article.

Tom said...

Nicely explained post, it helped me a lot

Anonymous said...

I've finally located what I was seeking! I'm overjoyed. What I've been looking for over a very long period is in your article. I'm glad to see you in this situation. Visit Random winner generator free, an intuitive online tool that enables you to quickly and simply select a name from a list of names at random as the winner.

Post a Comment