sshnet / SSH.NET

SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.
MIT License
3.87k stars 915 forks source link

System.NotSupportedException: Request 'ping' is not supported. #1413

Open anandgmenon opened 3 weeks ago

anandgmenon commented 3 weeks ago

I am from the Azure Logic apps team and we use the library in the SFTP connector there. For one of the users (SFTP server used is in-house system developed using Golang) we are seeing the ListDirectory method intermittently fails with the below exception

System.NotSupportedException: Request 'ping' is not supported.
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.SftpClient.EndListDirectory(IAsyncResult asyncResult)
   at Microsoft.Azure.Workflows.ServiceProviders.Sftp.Clients.SftpClientWrapper.EndListDirectory(IAsyncResult asyncResult)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)

Our code looks like this

var authenticationMethods = new List<AuthenticationMethod>();

authenticationMethods.Add(new PasswordAuthenticationMethod(
    username: key.Username,
    password: key.Password));

var sftpConnectionInfo = new ConnectionInfo(
    host: key.Host,
    username: key.Username,
    port: key.Port,
    authenticationMethods: authMethods.ToArray());

client.Connect();

var directoryContents = await Task.Factory
    .FromAsync(
        beginMethod: (asyncCallback, state) => client.BeginListDirectory(
            path: targetDirectory,
            asyncCallback: asyncCallback,
            state: state),
        endMethod: client.EndListDirectory,
        state: null)
   .ConfigureAwait(continueOnCapturedContext: false);

We saw a similar issue https://github.com/sshnet/SSH.NET/issues/638 and noticed the fix is merged. However we tried with the latest bits from develop branch and noticed the issue persists.

Please provide your inisights on the issue and let us know if there's a workaround or fix possible.

Rob-Hague commented 3 weeks ago

If I perform a regex search in the project for "Request.*is not supported", I do not get any results. Perhaps you can check you do have 70a0a08dae410df014fe33267087821026ccc27e? What commit do you have as latest?

anandgmenon commented 3 weeks ago

When we tested we had https://github.com/sshnet/SSH.NET/commit/749a0e00749d2d6d92422a755ff1fafbb655916b as the last commit, which included https://github.com/sshnet/SSH.NET/commit/70a0a08dae410df014fe33267087821026ccc27e

mus65 commented 3 weeks ago

I don't see how this could still happen with 749a0e00749d2d6d92422a755ff1fafbb655916b . As Rob mentioned, the error message doesn't even exist in the code anymore. I assume you have some mistake in your build or deployment and are actually still running an older version.

anandgmenon commented 3 weeks ago

Oh maybe some issues on build from my end, but would it be possible to release a new version so that its easier for us to test?

mus65 commented 3 weeks ago

Note that there is also a workaround for older version ,see https://github.com/sshnet/SSH.NET/discussions/1218#discussioncomment-7400286

anandgmenon commented 1 week ago

@mus65 the workaround for the old version didn't work, but we tried the latest version and seems to be working. However we'll need a new release to fix it officially. Last time @Rob-Hague mentioned there would be release in May. Can we get a release soon?