Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disconnects from server every 60 seconds when using FTP and FTPS #159

Open
petejfh opened this issue Jan 22, 2024 · 4 comments
Open

Disconnects from server every 60 seconds when using FTP and FTPS #159

petejfh opened this issue Jan 22, 2024 · 4 comments

Comments

@petejfh
Copy link

petejfh commented Jan 22, 2024

I'm doing a recursive delete of a folder which contains ~4000 files split over ~60 subfolders and have noticed that FileZilla is being disconnected every 60 seconds. It re-establishes the connection and continues the delete, but the disconnection pattern continues. The server is hosted remotely to the client.

FileZilla version: 3.65.0 on Windows 11
Protocol: FTPS (TLS 1.3)
Server Host: Linux Rocky el9
Server Host .NET version: 8

Output from the FileZilla log shows:

  • 2024-01-22 19:37:57 32424 1 Error: Connection closed by server
  • 2024-01-22 19:38:57 32424 1 Error: Connection closed by server
  • 2024-01-22 19:39:57 32424 1 Error: Connection closed by server
  • 2024-01-22 19:40:57 32424 1 Error: Connection closed by server
  • 2024-01-22 19:41:57 32424 1 Error: Connection closed by server
  • 2024-01-22 19:42:57 32424 1 Error: Connection closed by server
  • 2024-01-22 19:43:57 32424 1 Error: Connection closed by server

Example output from the FTP server shows for one of these events:

  • Jan 22 19:40:57 Stopped sending responses, from FubarDev.FtpServer.FtpConnection
  • Jan 22 19:40:57 Stopped reading command, from FubarDev.FtpServer.FtpConnection
  • Jan 22 19:40:57 Sending the response cancelled: 426 Connection closed; transfer aborted, from FubarDev.FtpServer.Commands.DefaultFtpCommandDispatcher
  • Jan 22 19:40:57 Connection closed, from FubarDev.FtpServer.FtpConnection

Any ideas on why these disconnects are happening every 60 seconds?

I see the same behaviour with .NET 6 too.

@petejfh
Copy link
Author

petejfh commented Jan 22, 2024

I'm also seeing the same behaviour using plain FTP (i.e. non-FTPS).

@petejfh petejfh changed the title Disconnects from server every 60 seconds when using FTPS Disconnects from server every 60 seconds when using FTP and FTPS Jan 22, 2024
@fubar-coder
Copy link
Contributor

I'll have to look into this, but I assume that some kind of idle connection timer is kicking in.

@tjipke-fg
Copy link

We had this same issue and I investigated it and came to the following conclusion: By default FtpConnectionIdleCheck is registered as a singleton (for IFtpConnectionCheck). However the code in it assumes it is instantiated for each connection.
I found a workaround for it, by first calling DisableIdleCheck on the builder (in AddFtpServer ) to remove that existing Singleton registration and then registering the FtpConnectionIdleCheck again but now as Scoped.

So my code now looks like this:

            // Add FTP server services
            services
               .AddFtpServer(
                    builder =>
                    {
                        // fix bug in FTPConnectionidleCheck being resolved as Singleton, where it should be Scoped
                        builder.DisableIdleCheck()
                            .Services.AddScoped<IFtpConnectionCheck, FtpConnectionIdleCheck>();
...

And this seems to work correct

@tjipke-fg
Copy link

Extra info: the disconnects happened only after the FTP server was running for at least 5:00 minutes after the first FTP connection was made (since the default timeout is 5 mins and the idle check was registered on the first FTP connection)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants