Hi,

I try to connect to the sFTP server. May be it is too busy and I can connect to it only after ~30sec (using for example WinSCP client). But using Rebex on the 20th second I got timeout exception (see details below). Timeout property is not affect on it (it is set to the 300*1000).

Thank you!

Exception stacktrace:

Rebex.Net.ProxySocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> Rebex.Net.ProxySocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond [server address]:22
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
   at wWGvS.BnRMAeZ.kRCyw(String , IPAddress , Int32 )
   --- End of inner exception stack trace ---
   at wWGvS.BnRMAeZ.kRCyw(String , IPAddress , Int32 )
   --- End of inner exception stack trace ---
   at wWGvS.BnRMAeZ.YqGDG(IAsyncResult , String )
   at wWGvS.BnRMAeZ.cCoahHZ(IAsyncResult , Int32 )
   at Rebex.Net.ProxySocket.Connect(String serverName, Int32 serverPort)
   at Rebex.Net.Sftp.Connect(String serverName, Int32 serverPort, SshParameters parameters)
* Rebex.Net.SftpException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> Rebex.Net.SftpException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> Rebex.Net.ProxySocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> Rebex.Net.ProxySocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond [server address]6:22
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
   at wWGvS.BnRMAeZ.kRCyw(String , IPAddress , Int32 )
   --- End of inner exception stack trace ---
   at wWGvS.BnRMAeZ.kRCyw(String , IPAddress , Int32 )
   --- End of inner exception stack trace ---
   at wWGvS.BnRMAeZ.YqGDG(IAsyncResult , String )
   at wWGvS.BnRMAeZ.cCoahHZ(IAsyncResult , Int32 )
   at Rebex.Net.ProxySocket.Connect(String serverName, Int32 serverPort)
   at Rebex.Net.Sftp.Connect(String serverName, Int32 serverPort, SshParameters parameters)
   --- End of inner exception stack trace ---
   at Rebex.Net.Sftp.Connect(String serverName, Int32 serverPort, SshParameters parameters)
   --- End of inner exception stack trace ---
   at Rebex.Net.Sftp.YqGDG(IAsyncResult , MethodBase )
   at Rebex.Net.Sftp.EndConnect(IAsyncResult asyncResult)

asked 06 Oct '11, 13:15

Maxim%20Shoshin's gravatar image

Maxim Shoshin
15
accept rate: 0%

edited 06 Oct '11, 14:58

Lukas%20Pokorny's gravatar image

Lukas Pokorny ♦♦
2.4k28


This exception was thrown by .NET's Socket class as a result of an error reported by Winsock, Windows TCP subsystem. Winsock has its own timeout values and some of them (including Connect timeout) can't be affected by applications.

If interested, check out the Winsock FAQ for more information – while it is possible for an application to make connection attempts fail sooner than TCP subsystem timeout occurs (and the FAQ describes how), it's not possible to make it wait longer. If the Connect method times out after 20 seconds, we can't change that.

However, this should affect all applications including WinSCP. Perhaps WinSCP tries re-connecting after it gets this kind of error? You can reproduce that kind of behavior with Rebex SFTP as well - catch the SftpException thrown by the Connect method, check its Status or Inner Exceptions to make sure it's this error and try again if needed.

link

answered 06 Oct '11, 15:07

Lukas%20Pokorny's gravatar image

Lukas Pokorny ♦♦
2.4k28
accept rate: 31%

But you can use non blocking Socket.BeginConnect method instead Socket.Connect.

For example: http://stackoverflow.com/questions/1062035/how-to-config-socket-connect-timeout-in-c

(06 Oct '11, 15:18) Maxim Shoshin

Unfortunately, non-blocking BeginConnect would time out as well. Even the example in the link discusses ways to make it time out sooner (which is possible, as I stated above), not ways to make it time out later.

Try the following code:

using System.Net;
using System.Net.Sockets;
...

Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IAsyncResult ar = socket.BeginConnect(serverName, 22, null, null);
socket.EndConnect(ar);
(06 Oct '11, 15:32) Lukas Pokorny ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×141
×23
×20

Asked: 06 Oct '11, 13:15

Seen: 710 times

Last updated: 06 Oct '11, 15:32