Skip to content
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

TimeOut in Connect on iOS #1476

Open
TomQv opened this issue Aug 25, 2024 · 2 comments
Open

TimeOut in Connect on iOS #1476

TomQv opened this issue Aug 25, 2024 · 2 comments

Comments

@TomQv
Copy link

TomQv commented Aug 25, 2024

I'm only receiving Timeout-Exception trying to connect to my ftp-server with iOS:

var client = new SftpClient("files.qvgps.com", “user”, “password");
client.Connect();
Renci.SshNet.Common.SshOperationTimeoutException: Connection failed to establish within 30000 milliseconds.
  at Renci.SshNet.Abstractions.SocketAbstraction.ConnectCore (System.Net.Sockets.Socket socket, System.Net.EndPoint remoteEndpoint, System.TimeSpan connectTimeout, System.Boolean ownsSocket) [0x000a4] in <f1d5e967bcbc48fcb33dd5c4b79edfbe>:0
  at Renci.SshNet.Abstractions.SocketAbstraction.Connect (System.Net.Sockets.Socket socket, System.Net.EndPoint remoteEndpoint, System.TimeSpan connectTimeout) [0x00000] in <f1d5e967bcbc48fcb33dd5c4b79edfbe>:0
  at Renci.SshNet.Connection.ConnectorBase.SocketConnect (System.Net.EndPoint endPoint, System.TimeSpan timeout) [0x0000e] in <f1d5e967bcbc48fcb33dd5c4b79edfbe>:0

With UWP, it works fine.

SSH.NET 2024.1.0
Visual Studio Community 2022 for Mac
Version 17.6.12 (build 410)
Xamarin.iOS
Version: 16.4.0.23 Visual Studio Community

Are there maybe any additional steps required on iOS to use sftp?

@TomQv
Copy link
Author

TomQv commented Aug 25, 2024

Ok, did some more tests, seems like is was my router. I disconnected from Wifi and used mobile data, then it worked. Then I restarted my router and then it also worked with Wifi. No timeouts anymore.
Strange, but it looks like, as it was no SSH.NET problem.

@Rob-Hague
Copy link
Collaborator

Yeah so despite the stack trace the real problem is waiting too long in Socket.Connect:

throw new SshOperationTimeoutException(string.Format(CultureInfo.InvariantCulture,
"Connection failed to establish within {0:F0} milliseconds.",
connectTimeout.TotalMilliseconds));

I imagine (or hope) you would observe a similar hang without the library:

using System.Net.Sockets;

using var socket = new Socket(SocketType.Stream, ProtocolType.Tcp);

socket.Connect("files.qvgps.com", 22);

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

No branches or pull requests

2 participants