如何在C#中使用sftp获取大量文件时删除列表超时问题? [英] How to remove list time out issue while fetching large volume of files using sftp in C#?

查看:123
本文介绍了如何在C#中使用sftp获取大量文件时删除列表超时问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在c#中使用sftp获取大量文件时遇到列表超时问题。我能够获取和下载高达50k的文件。但如果在70k左右的范围内达到以下异常:

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.





通过数据库呼叫区域输出命令超时Sql DB服务器。但问题仍然存在。



我尝试过:





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"));



并保存< br $>



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();

推荐答案

您是否尝试过增加ftpwebrequest对象的Timeout属性?该值表示毫秒。



FileZilla(一种流行的FTP客户端)使用默认值20秒,这不足以获取/放置任何大量文件,所以我不得不将连接超时时间增加到30分钟。
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.


这篇关于如何在C#中使用sftp获取大量文件时删除列表超时问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆