SftpClient.Connect - Session operation has timed out.

Jul 24, 2013 at 3:06 PM
I'm trying to do a simple connect to SFTP and upload a file. However it always fails on the Connect() with the error 'Session operation has timed out.' It does appear to have gotten past the login/authentication because I get a different error message if I purposely use an incorrect user/passsword. The SFTP connection does work with another client (filezilla and putty).

The code (below) is trivial so I'm not sure what needs to be added/changed.

SftpClient c = new SftpClient(sHost,iPort, sUser, sPass);

Any ideas?

Jul 24, 2013 at 8:19 PM
Hey Tim,

I'm hitting the same issue using a different method, we might have same problem. The previous post I started about PrivateKeyAuthentication works on my dev server. I moved it over to the production server (the key) and it fails on line 3 below with "Operation has timed out":
                var webClient = new WebClient();
                webClient.Headers.Set(Program._key_header_name, Program._key_header_value);
                String sensorKey = webClient.DownloadString(Program._key_url);
                var sensorKeyBytes = new MemoryStream(Encoding.Default.GetBytes(sensorKey));
The DownloadString method returns a "Operation has timed out" after about 30 seconds or so. If you are savvy with Wireshark, that got me going in a direction. I noticed on frame 7 of the handshake exchange that the Production server was returning "Warning, Description: unrecognized Name), Server Hello" while the development server did not. So I started looking at the certificate name of the prod server, and noticed it was using lots of aliases, while the development server was not. This might be the name issue its referring to in the WireShark packet capture. I'm still working the issue, no luck yet, but thought it might josh you into a direction.

Our issues might be completely different too though, since I'm using a WebClient and you are using SftpClient in which case I'll probably start a new thread on it.
Jul 25, 2013 at 3:23 AM
Thanks. That might help but I'm not quite sure what I'm looking at. Wireshark shows the various frames sent to and from the server. The point of interest is frame frame 25 is sent from the server to the client, and the client sends back an ACK in frame 26. After that nothing happens until the timeout passes (increasing the timeout just means it waits longer). After which the client sends an encrypted request which the server response to with a FIN/ACK and then the client sends a RST/ACK and closes the port.

I'm not sure what the client would be waiting on at that point. It appears that all encrypted requests have received an encrypted response.
Jul 25, 2013 at 3:46 AM
I'm not sure it helps any. But I also get "An operation was attempted on something that is not a socket" occasionally.
Jul 26, 2013 at 1:00 AM
Dunno buddy. That is a bit odd. It almost sounds as if its connecting to a socket that isn't open on the server. But if WireShark shows connectivity back and forth, then it is open.

Sorry I couldn't help more.