Skip to content

SftpClient.ConnectAsync hangs #1411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
timurposhva opened this issue May 22, 2024 · 5 comments · Fixed by #1502
Closed

SftpClient.ConnectAsync hangs #1411

timurposhva opened this issue May 22, 2024 · 5 comments · Fixed by #1502

Comments

@timurposhva
Copy link

timurposhva commented May 22, 2024

Hi!

When connecting to the sftp server, the method SftpClient.ConnectAsync hangs(timeout not working).

My configuration:
Timeout: 60s
OperationTimeout: 10s

OS: windows server 2019
SSH.NET version: 2024.0.0
NET version: 8.0

Stack trace:

System.OperationCanceledException: The operation was canceled. at System.Threading.CancellationToken.ThrowOperationCanceledException() at System.Threading.CancellationToken.ThrowIfCancellationRequested() at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken) at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Int32>.GetResult(Int16 token) at Renci.SshNet.Connection.ProtocolVersionExchange.SocketReadLineAsync(Socket socket, List1 buffer, CancellationToken cancellationToken) at Renci.SshNet.Connection.ProtocolVersionExchange.StartAsync(String clientVersion, Socket socket, CancellationToken cancellationToken) at Renci.SshNet.Session.ConnectAsync(CancellationToken cancellationToken) at Renci.SshNet.BaseClient.CreateAndConnectSessionAsync(CancellationToken cancellationToken) at Renci.SshNet.BaseClient.ConnectAsync(CancellationToken cancellationToken)

Thank you in advance!

@Rob-Hague
Copy link
Collaborator

Looks like the very initial protocol handshake is timing out. Are you able to connect to this server with any other SFTP client e.g. WinSCP?

@timurposhva
Copy link
Author

timurposhva commented May 22, 2024

Looks like the very initial protocol handshake is timing out. Are you able to connect to this server with any other SFTP client e.g. WinSCP?

I can connect using SSH.NET or WinSCP. But the SSH.NET stops responding from time to time. The synchronous version SftpClient.Connect works fine.

@Rob-Hague
Copy link
Collaborator

So do you mean that both Connect and ConnectAsync do not successfully connect, but Connect respects ConnectionInfo.Timeout while ConnectAsync doesn't, or that Connect() connects successfully but ConnectAsync() doesn't?

@timurposhva
Copy link
Author

timurposhva commented May 23, 2024

Connect respects ConnectionInfo.Timeout while ConnectAsync doesn't?

correct

@djfoxer
Copy link

djfoxer commented Jul 15, 2024

Yup, I had excalty same issue. ConnectAsync never ends but Connect ends (with fail message) after ConnectionInfo.Timeout seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants