sshnet / sshnet/SSH.NET

SSH.NET - Socket read operation has timed out after 30000 milliseconds.

オープン
#889 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
C#
スター
4.4k
フォーク
993
平均マージ
9日 21時間
マージ済み PR(30日)
1

説明

Hi @drieseng I'm getting issue also on my SFTP setup using the SSH.NET latest version using .NET 5.0. It works fine until I got this issue.

Socket read operation has timed out after 30000 milliseconds.

This is my current code.

using (SftpClient sftpClient = new SftpClient(await getSftpConnection(export.Schedule.Host,
export.Schedule.Username,
export.Schedule.Password,
export.Schedule.KeyFile,
export.Schedule.Parapharase,
export.Schedule.LogonType, log)))

    {
        try
        {
            if (!sftpClient.IsConnected)
            {
                log.LogInformation($"Connecting Sftp....");
                do
                {
                    try
                    {
                        sftpClient.Connect();
                    }
                    catch (Renci.SshNet.Common.SshConnectionException e)
                    {
                        log.LogInformation($"Connection error: {e.Message}");
                    }
                } while (!sftpClient.IsConnected);

                log.LogInformation($"Done connecting Sftp");
            }
                    //Send file per devicename
                    foreach (var _perDevice in export.ExportTablePerDevice)
                    {
                        log.LogInformation($"Device {_perDevice.DeviceName}");
                        try
                        {
                            var csv = export.Schedule.Layout.Equals("LAYOUT 05") ? ReportHelper.ConvertToDat(export.ExportTable) :
                                ReportHelper.ConvertToCsv(_perDevice.ExportTable, export.Schedule.Layout, _perDevice.TopUserHeader);

                            var stream = ZipArchiveExtensions.GenerateStreamFromString(csv);

                            string filename = "";
                            if (export.IsExportDevices)
                            {
                                filename = _perDevice.DeviceName.Replace(@"/", "_") + "_" + DateTime.Now.Ticks + "." + export.Schedule.ExportFormat.ToLower() ?? "csv";
                            }
                            else
                            {
                                    filename = (!String.IsNullOrEmpty(export.Schedule.FileName) ? export.Schedule.FileName.Replace(@"/", "_").Replace("#tick", DateTime.Now.Ticks.ToString()) :
                                       _perDevice.DeviceName.Replace(@"/", "_") + DateTime.Now.Ticks) + "." + export.Schedule.ExportFormat.ToLower() ?? "csv";
                            }
                            var file = $"/{export.Schedule.FilePath}/{filename}";
                            await sftpClient.UploadAsync(stream, file);
                        }
                        catch (Exception ex)
                        {
                            sftpClient.Disconnect();
                            sftpClient.Dispose();
                            log.LogInformation($"Device error: {ex.Message}");
                        }
                    }
            sftpClient.Disconnect();
            response = new StatusCodeResponse()
            {
                Code = HttpStatusCode.OK.ToString(),
                HttpStatus = (int)HttpStatusCode.OK,
                Message = $"Successfully sent export {export.Schedule.Name} via sftp server"
            };

        }
        catch (Exception ex)
        {
            sftpClient.Disconnect();
            log.LogInformation($"An exception has been caught {ex.Message}");
            response = new StatusCodeResponse()
            {
                HttpStatus = (int)HttpStatusCode.InternalServerError,
                Code = HttpStatusCode.InternalServerError.ToString(),
                Message = $"Error sending export {export.Schedule.Name} via sftp server: {ex.Message}"
            };
        }
    }

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

提供された C# の例から始め、報告されている 30 秒のソケット読み取りタイムアウトに関連する SftpClient.Connect と UploadAsync に焦点を当てます。説明されている .NET 5.0 SFTP セットアップで障害を再現し、それを引き起こすサーバー、接続、またはアップロードの条件を特定してください。リポジトリのファイルもテストも指定されていないため、完了基準はまだ定義されていません。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
csharp
領域
networking
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
20/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。