sshnet / sshnet/SSH.NET

SftpClient and Thread Safety

Open
#669 2 comments 5 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 can't find any information on thread safety regarding ssh.net. I'm using SftpClient and sharing this accross multiple threads to download files, is this ok to do or should a client be created for each thread downloading a file?

It seems to work but on occasions the the downloads (3 of them) hang for around 5 minutes.

image

If pause the application I can see the following threads. I will do more investigation tomorrow, as I haven't ruled out the SFTP server either.

As a start if someone could answer if this is Thread safe and that downloading multiple files on different threads using a shared SftpClient is ok I would be appreciated.

Michael.

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

Start with SftpClient and the reported concurrent downloads, then investigate whether shared use across threads is supported and whether the hangs are reproducible. The issue names no source files or tests; done means documenting the supported usage and any relevant concurrency limitations or guidance.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.