Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am getting list time out issue while fetching large volume of files using sftp in c#. I am able to fetch and download files up to 50k. But if in the range of above 70k or so getting below exception:
ListTimeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.


Gave command time out in the Database Calling areas via Sql DB Server. But still the issue persists.

What I have tried:

_listSftp.ListItemReceived += (s, e) =>
                    {
                        SftpItem item = e.Item;
                        objSFTPFile = new SFTPFile();
                        objSFTPFile.FileType = "DDS300";
                        objSFTPFile.Extension = "DDR";
                        objSFTPFile.Status = SFTPStatus.L.ToString();
                        objSFTPFile.FileName = item.Name.Trim();
                        objSFTPFile.FileSize = item.Size;
                        objSFTPFile.Mode = SFTPMode.D.ToString();
                        objSFTPFile.BankCode = Common.BANKCODE;
                        ListSFTPFile.Add(objSFTPFile);
                        Common.WriteLog(MethodInfo.GetCurrentMethod().Name + " FileType: " + objSFTPFile.FileType + " FileName: " + objSFTPFile.FileName, ServiceThread.Listing.ToString());
                        // skip adding item to resulting collection
                        e.Ignore();
                    };

                    // clear resulting collection first
                    ListSFTPFile.Clear();

                    // issue directory listing
                    SftpItemCollection List = _listSftp.GetList(GetSFTPServerPath("Files"));

and saving

string strxml = DAL_Common.getXMLFromList(listInwardFile);
               DataSet dsDetails = new DataSet();
               DbCommand DbCmd = DataAccessBase.Database.GetStoredProcCommand("DDS_SAVE_SFTP_DOWNLOAD_LIST");
               DbCmd.CommandTimeout = 600;

               DataAccessBase.Database.AddInParameter(DbCmd, "@p_BankCode", DbType.String, strBankCode);
               DataAccessBase.Database.AddInParameter(DbCmd, "@p_xml", DbType.Xml, strxml);
               DataAccessBase.Database.AddOutParameter(DbCmd, "@p_error_code", DbType.String, 40);
               DataAccessBase.Database.AddOutParameter(DbCmd, "@p_error_msg", DbType.String, 1000);

               int i = DataAccessBase.Database.ExecuteNonQuery(DbCmd);
               int ErrorCode = Convert.ToInt32(DataAccessBase.Database.GetParameterValue(DbCmd, "@p_error_code").ToString());
               Errormsg = DataAccessBase.Database.GetParameterValue(DbCmd, "@p_error_msg").ToString();
Posted
Updated 28-Feb-18 15:30pm
v2

1 solution

Have you tried increasing the ftpwebrequest object’s Timeout property? The value represents milliseconds.

FileZilla (a popular FTP client) uses a default value of 20 seconds which isn't long enough to get/put any significant number of files, so I had to increase the connection timeout to 30 minutes.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900