When using AutoConnect on an FTP server which is not available it waits forever
FTP OS: External party - no insights FTP Server: External party - no insights
Computer OS: Azure Function v3/Windows
FluentFTP Version: 32.4.5
When using AutoConnect on an FTP server which is available, everything works as expected. However, as soon as the FTP server becomes unavailable and you try to connect using AutoConnect, it will wait forever (at least 6 hours). I would expect that it throws an exception.
When using just the regular Connect method, I can either connect to the FTP server or when it's not available, it will just throw a 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." which is something I would expect.
Please do a check on this as it can give really strange behavior in an application.
But how will the system differentiate between a legit failure to connect and a SocketException indicating the server is unreachable? Should I abort the AutoConnect only if I receive a specific kind of SocketException?
When looking at the Source Code of the AutoConnect or especially AutoDetect, it loops trough all possible ways to connect to connect to an FTP server. I would expect that if the client is not able to connect to the FTP server in any of the possible options that are detected with AutoDetect, or if one of the connection attempts is throwing any exception.
My assumption would be that in the AutoDetect method at line 126 for one of the possible combinations it will wait forever (it just keeps trying). Wouldn't it be an idea to have some kind of timeout option which can be configured?
// try to connect
var connected = false;
try {
conn.Connect();
connected = true;
conn.Dispose();
}
catch (Exception ex) {
conn.Dispose();
}
There is already a connection timeout of 15 seconds by default.
Does this work? FluentFTP.32.4.6_BETA.zip
Btw what do you mean by "not available"? Is it an invalid host, an FTP server that hangs/not responding, in other words, how do I replicate this to test it?
Sorry for the delay, I will try to come back on the results tomorrow. By "not available" I mean that the FTP server we are connecting to, is disabled or shut-down. This can be during the night or during (un)expected maintenance.
Unfortunately no success. I know the FTP server is available from 6am. So I've let my Azure Function trying to connect from 3am, every 20 minutes. However, it did try to connect at 3am and stayed waiting for almost 3 hours (until 6am) and then the connection succeeded. When I would have started trying to connect earlier, it would have been waiting even longer. I cannot see why it is waiting, there is no log output at that moment.