Discuss (FTP), (FTP on .NET CF) and (FTPS, SFTP and SCP).
no avatar
User

dlangell

Posts

20

Joined

Tue Jun 20, 2006 11:25 pm

Inconsistent Connection Refused exceptions

by dlangell » Wed May 13, 2015 11:57 pm

Let's say my server can support either FTP or SCP, but I don't know which. If it's using SCP and my SecureFTPConnection client is set to the FTP protocol, I will quickly get a SocketException (10061 Connection Refused). This is nice because I can catch the exception, check for the 10061 code, and switch to using SCP instead because I know FTP isn't supported.

Now consider the other direction. The server is using FTP, but my client is set to the SCP protocol. In this case I get an IOException with the message "Failed to connect to 192.168.43.45:22 within timeout 10000 ms" and this exception is actually raised pretty quickly instead of after the full timeout. Not so nice because an IOException can be raised for a multitude of other reasons (actual timeouts because the server is not present, other timeouts like DNS issues, etc). So it's harder to know with the IOException what the true reason is. Did it really time out? Was the protocol unsupported?

So what's the difference? Why do I get an IOException instead of a SocketException which would be more helpful? Is there an easier way to know that the protocol being used isn't supported? My current plan if I get an IOException is to try a basic TCP connection afterwards with a short timeout using a raw socket and catching the 10061 SocketException myself so I know whether the connection is being actively refused. And in this case I'll actually ask the user if they want to use an unsecure connection instead. But it would sure be nice if I knew this from the SecureFTPConnection client itself.

FYI, I think I also get the same scenarios when choosing between SFTP and FTP, but I haven't been able to fully test this.
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

Re: Inconsistent Connection Refused exceptions

by support2 » Thu May 14, 2015 12:58 am

Maybe post a snippet of debug level logging from the SCP protocol attempt to port 22 - it might tell us something.
no avatar
User

dlangell

Posts

20

Joined

Tue Jun 20, 2006 11:25 pm

Re: Inconsistent Connection Refused exceptions

by dlangell » Thu May 14, 2015 1:19 am

Here you go. In this case my server only supported FTP but I was trying to connect using the SCP protocol. The connection attempt fails after about a second (which is good since it's not waiting the entire 10 seconds for my timeout) and I receive the failure as an IOException instead of a SocketException.

INFO [FTPConnection] 13 May 2015 11:13:43.048 : OS: 6.2.9200.0, CLR: 4.0.30319.34209, DLL: 8.6.6.20
INFO [FTPConnection] 13 May 2015 11:13:43.049 : Built: 15-Apr-2015 20:01:37 BST
DEBUG [LicenseProperties] 13 May 2015 11:13:43.050 : Looking for subkey Software\Enterprise Distributed Technologies\edtFTPnet PRO (fallback )
DEBUG [LicenseProperties] 13 May 2015 11:13:43.050 : Found license subkey Software\Enterprise Distributed Technologies\edtFTPnet PRO
DEBUG [LicenseProperties] 13 May 2015 11:13:43.051 : Looking for subkey Software\Enterprise Distributed Technologies\edtFTPnet PRO (fallback )
DEBUG [LicenseProperties] 13 May 2015 11:13:43.051 : Found license subkey Software\Enterprise Distributed Technologies\edtFTPnet PRO
DEBUG [LicenseProperties] 13 May 2015 11:13:43.054 : Looking for subkey Software\Enterprise Distributed Technologies\edtFTPnet PRO (fallback )
DEBUG [LicenseProperties] 13 May 2015 11:13:43.054 : Found license subkey Software\Enterprise Distributed Technologies\edtFTPnet PRO
DEBUG [LicenseProperties] 13 May 2015 11:13:43.054 : Looking for subkey Software\Enterprise Distributed Technologies\edtFTPnet PRO (fallback )
DEBUG [LicenseProperties] 13 May 2015 11:13:43.054 : Found license subkey Software\Enterprise Distributed Technologies\edtFTPnet PRO
DEBUG [SFTPMessageStore] 13 May 2015 11:13:43.061 : Set timeout=10000
INFO [LicenseProperties] 13 May 2015 11:13:43.066 : Licence expiry date: 12/31/9999
INFO [LicenseProperties] 13 May 2015 11:13:43.066 : Production license
INFO [LicenseProperties] 13 May 2015 11:13:43.067 : Licence expiry date: 12/31/9999
INFO [LicenseProperties] 13 May 2015 11:13:43.067 : Production license
DEBUG [SSHSCPClient] 13 May 2015 11:13:43.068 : Setting up fallback kbi prompt based on supplied password
DEBUG [HostNameResolver] 13 May 2015 11:13:43.071 : Resolving 192.168.43.40
DEBUG [HostNameResolver] 13 May 2015 11:13:43.072 : 192.168.43.40 resolved to 192.168.43.40
DEBUG [SSHSCPClient] 13 May 2015 11:13:43.072 : Connecting directly to SFTP server 192.168.43.40:22
INFO [BaseSocket] 13 May 2015 11:13:43.072 : Connecting to 192.168.43.40:22 with timeout 10000 ms
ERROR [BaseSocket] 13 May 2015 11:13:44.096 : Failed to connect to 192.168.43.40:22 within timeout 10000 ms
DEBUG [FTPConnection] 13 May 2015 11:13:44.111 : Closing connection [instance=0,abrupt=False]
WARN [FTPConnection] 13 May 2015 11:13:44.126 : Caught exception closing connection: The SFTP client has not yet connected to the server. The requested action cannot be performed until after a connection has been established.
DEBUG [SFTPMessageStore] 13 May 2015 11:13:44.126 : Set timeout=5000
DEBUG [FTPConnection] 13 May 2015 11:13:44.127 : Closing connection [instance=0,abrupt=False]
WARN [FTPConnection] 13 May 2015 11:13:44.130 : Caught exception closing connection: The SFTP client has not yet connected to the server. The requested action cannot be performed until after a connection has been established.
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

Re: Inconsistent Connection Refused exceptions

by support2 » Fri May 15, 2015 8:26 am

It's not obvious what's happening. We will try to replicate it.

Who is online

Users browsing this forum: No registered users and 22 guests

Powered by phpBB ® | phpBB3 Style by KomiDesign
cron