sshnet / sshnet/SSH.NET

SftpClient UploadFile throws SocketException: 'An existing connection was forcibly closed by the remote host'

Open
#950 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

This exception has been thrown when VPN client is connected. Same code works fine if VPN is switch off.

image

StackTrace:

at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at Renci.SshNet.Abstractions.SocketAbstraction.Send(Socket socket, Byte[] data, Int32 offset, Int32 size)
at Renci.SshNet.Session.SendPacket(Byte[] packet, Int32 offset, Int32 length)
at Renci.SshNet.Session.SendMessage(Message message)
at Renci.SshNet.Session.Renci.SshNet.ISession.SendMessage(Message message)
at Renci.SshNet.Channels.Channel.SendData(Byte[] data, Int32 offset, Int32 size)
at Renci.SshNet.Channels.Channel.SendData(Byte[] data)
at Renci.SshNet.SubsystemSession.SendData(Byte[] data)
at Renci.SshNet.Sftp.SftpSession.SendRequest(SftpRequest request)
at Renci.SshNet.Sftp.SftpSession.RequestWrite(Byte[] handle, UInt64 serverOffset, Byte[] data, Int32 offset, Int32 length, AutoResetEvent wait, Action1 writeCompleted) at Renci.SshNet.SftpClient.InternalUploadFile(Stream input, String path, Flags flags, SftpUploadAsyncResult asyncResult, Action1 uploadCallback)
at Renci.SshNet.SftpClient.UploadFile(Stream input, String path, Boolean canOverride, Action`1 uploadCallback)

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 reproducing SftpClient.UploadFile with the reported VPN condition, then trace the failure through SftpClient.InternalUploadFile, SftpSession.RequestWrite, Session.SendPacket, and SocketAbstraction.Send. Compare behavior with and without the VPN and determine whether the issue can be isolated to a reproducible library or environment condition; done means documenting the cause and an actionable fix or limitation.

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
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.