connect takes forever

Oct 28, 2011 at 10:20 AM
Edited Oct 28, 2011 at 10:24 AM

I'm using the following code to connect to an SFTP-server:

SFTP = New Renci.SshNet.SftpClient(Me.RemoteServerAddress, Me.RemoteServerPort, Me.RemoteServerUsername, Me.RemoteServerPassword)
With SFTP
    Dim t As TimeSpan = New TimeSpan(0, 0, Me.TimeOut / 1000)
    .OperationTimeout = t
    .Connect()
End With

Usually it works and connects to the SFTP-server properly. However it also occurs that the connection cannot be established, and the code "hangs" on the Connect()-statement. The timeout doesn't seem to work, or did I do something wrong? Me.TimeOut is set to 30000, so after 30 seconds it should stop trying to connect and continue with the rest of the code.

The runtime version of Renci.SshNet.dll is v4.0.30319.

Coordinator
Oct 31, 2011 at 1:30 PM

Does it happens to different servers or only to specific one?

What happens if you trying to connect to other servers?

Also, somethign to try:

In Session.cs class find connect method and put a breakpoint on this line:

this.SocketConnect();

and see if code passes this line or not.

 

Thanks,

Oleg

Nov 3, 2011 at 8:39 AM

It only happens to a specific server, but we use this library only for one SFTP-server. I have created a windows service that connects to this specific SFTP-server every minute to check if there are any files ready for download. The specific connect-issue occurs rarely, let's say once in two days, so most of the times there are no problems connecting to this server. Also I have to say this error occurs at a customer of ours, but of course I could create a similar program here to connect to the SFTP-server regularly and leave it running to see if the connect-problem will occur and if the line "this.SocketConnect()" is passed or not.

Nov 4, 2011 at 1:07 PM

If you could help us create this program and test it, we would be very glad! Will you help?

Nov 10, 2011 at 3:40 PM

There is no "this.SocketConnect();" in my Session.cs file. There is a line "this.OpenSocket();" however. Anyway, I have set up a small test program that connects every minute, uploads and downloads a small file, and then disconnects, and I will let it run all night, hopefully the same situation will occur in this testing setup.