sshnet / sshnet/SSH.NET

"Session operation has timed out" on Azure Function

Open
#151 5 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

I'm try to connect to a SFTP server from an Azure Function and I keep getting a "Session operation has timed out". I'm on version "2016.0.0". I've build a similar function using WinSCP and that works fine and the same applies to running the CLI command SFTP from the Kudu prompt.

I'm using the following code:

public static void Run(TimerInfo myTimer, TraceWriter log)
{
string sftp_host = ;
string sftp_user = ;
string sftp_privateKey = @
var stream = new FileStream(sftp_privateKey, FileMode.Open, FileAccess.Read);
var privateKeyFile = new PrivateKeyFile(stream);
AuthenticationMethod authenticationMethod = new PrivateKeyAuthenticationMethod(, privateKeyFile);
ConnectionInfo ConnNfo = new ConnectionInfo(sftp_host, sftp_user, authenticationMethod);
SftpClient client = new SftpClient(ConnNfo);
try
{
client.Connect();

        }
        catch (Exception ex)
            {
                log.Info("Error Message: " + ex.Message);
                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

Start with the SftpClient connection setup shown in the issue, especially client.Connect(), and reproduce the timeout in the Azure Function environment. Compare its behavior with the working WinSCP and Kudu SFTP cases. Done means identifying a reproducible cause or actionable correction for the timeout; the issue does not name a repository file or test to update.

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.