sshnet / sshnet/SSH.NET

An existing connection was forcibly closed by the remote host

Open
#1,526 1 comment 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

Dear all,

we are using SSH.NET 2024.2.0.0 with a .NET 4.7.2 console application to download files via SFTP from our german provider Strato.

We sporadically have the problem that we receive the error 10054 (An existing connection was forcibly closed by the remote host) when downloading files. Sometimes this occurs after a few minutes and sometimes after a few seconds.

We have tried the following:

  1. Run our application on different PCs => Error occurs
  2. Waited between 200ms and 1000ms before downloading each file => error occurs
  3. Run app via on a different internet connection => Error occurs
  4. Used an internal SSH server => Error does not occur! In this test, we let it run for several hours

In all our tests, we simply downloaded files via SFTP in the loop and waited.

Then we followed the debug instruction of SSH.NET and compiled SSH.NET using the debug function and activated the trace.
If we have activated the trace, the error does not occur.
If we deactivate the source “System.Net.Sockets” in the trace and only activate the source “SshNet.Logging”, the problem occurs (trace attached)

If we have only activated “System.Net.Sockets” in the trace, the problem does not occur - regardless of whether we are using a TextWriter or a ConsoleWriter.

Due to the fact that it sometimes occurs when the trace is activated and sometimes not, we rather suspect a bug in SSH.NET. Especially because we used to download the files with WinSCP / Filezilla and never had any problems.

Here is the exception:
image

The trace trace.sshnet.log in the attachment.

trace.sshnet.log

Best regards

Rainer

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 by reviewing the attached trace.sshnet.log and the reported SocketException while reproducing the repeated SFTP download loop against the Strato server. Compare behavior with SshNet.Logging enabled versus System.Net.Sockets tracing. Done means identifying whether SSH.NET is responsible and documenting or implementing a verified fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking
Issue type
Bug
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.