sshnet / sshnet/SSH.NET

Set timeout for Uploading a file

Open
#241 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
4.4k
Forks
993
Avg merge
9d 21h
Merged PRs (30d)
1

Description

Hi,

I am trying to upload a file of 10 MB to SFTP using SSH.net but my program got stuck, if I try to upload same file manually I am getting below error :
Error: error while writing: received failure with description 'Failure'

I am not getting any error and the program is just stuck at uploading the file, so I appreciate your answers for below questions :

  • Why no error is returned.
  • How can I set the timeout for uploading a file, so in case uploading the file took more than 1 minute and I want to get timeout message ?

Snippet of my code:


     var con = # ConnectionInfo
     con.Timeout = new TimeSpan(0, 0, 1, 0); # connection Timeout
      using (var client = new SftpClient(con))
                {
                    var fileStream = new FileStream(filename, FileMode.Open);
                    string uploadFileName = ftpAcc.UploadPath; 
                    client.UploadFile(fileStream, uploadFileName, true, null);
                    client.Disconnect();
                }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No repository files or tests are named. Start by reproducing the upload with ConnectionInfo.Timeout and SftpClient.UploadFile from the provided snippet, then trace how the timeout is handled; done means an upload exceeding the configured limit reports a timeout instead of remaining stuck.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.