FubarDevelopment / FtpServer

Portable FTP server written in .NET
http://fubardevelopment.github.io/FtpServer/
MIT License
473 stars 161 forks source link

FileZilla uploading multiple large files parallel #85

Closed SebastianKuesters closed 4 years ago

SebastianKuesters commented 4 years ago

Hi,

I have found an issue when I am try to modify the default sample script:

What I have done? I have created an dotnet core web app using the following Program.cs code, which I have take from the quick start:

namespace WebApplication1
{
    internal class HostedFtpService : IHostedService
    {
        private readonly IFtpServerHost _ftpServerHost;

        /// <summary>
        /// Initializes a new instance of the <see cref="HostedFtpService"/> class.
        /// </summary>
        /// <param name="ftpServerHost">The FTP server host that gets wrapped as a hosted service.</param>
        public HostedFtpService(
            IFtpServerHost ftpServerHost)
        {
            _ftpServerHost = ftpServerHost;
        }

        /// <inheritdoc />
        public Task StartAsync(CancellationToken cancellationToken)
        {
            return _ftpServerHost.StartAsync(cancellationToken);
        }

        /// <inheritdoc />
        public Task StopAsync(CancellationToken cancellationToken)
        {
            return _ftpServerHost.StopAsync(cancellationToken);
        }
    }
    public class Program
    {
        public static void Main(string[] args)
        {
            CreateWebHostBuilder(args).Build().Run();
        }

        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .ConfigureServices(
                    services =>
                    {
                        // Add FTP server services
                        // DotNetFileSystemProvider = Use the .NET file system functionality
                        // AnonymousMembershipProvider = allow only anonymous logins
                        services
                            .AddFtpServer(
                                builder => builder
                                    .UseDotNetFileSystem()
                                    .EnableAnonymousAuthentication());

                        // Configure the FTP server
                        services.Configure<FtpServerOptions>(opt => opt.ServerAddress = "*");

                        // use %TEMP%/TestFtpServer as root folder
                        services.Configure<DotNetFileSystemOptions>(opt => opt
                            .RootPath = Path.Combine(Path.GetTempPath(), "TestFtpServer"));

                        Console.WriteLine("PATH: " + Path.GetTempPath());

                        // Add the FTP server as hosted service
                        services
                            .AddHostedService<HostedFtpService>();
                    })
                .UseStartup<Startup>();
    }
}

What is the problem? When I connect 1 client with 8 uploads at once to my FTP server which runs in an Ubuntu server on Azure and every client starts to upload a file bigger than 300MB then for most uploads will stuck at 100% in FileZilla and run into a timeout:

08:26:00    Befehl: STOR can-it-be-done-in-react-native-master.zip
08:26:00    Antwort:    150 Opening connection for data transfer.
08:27:25    Fehler: Zeitüberschreitung der Verbindung nach 20 Sekunden Inaktivität // Timeout
08:27:25    Fehler: Dateiübertragung fehlgeschlagen nach Übertragung von 247.897.864 Bytes in 401 Sekunden
08:27:25    Status: Verbindung zum Server getrennt

I would be very happy if you could help me with this issue!

Best, Sebastian

fubar-coder commented 4 years ago

I'm unable to reproduce the problem. Can you please enable server-side logging? You can do this by:

1. Add Microsoft.Extensions.Logging.Console to your project (skip if already added)

This is the new QuickStart.AspNetCoreHost.csproj file:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
    <IsPackable>false</IsPackable>
    <SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\..\src\FubarDev.FtpServer.FileSystem.DotNet\FubarDev.FtpServer.FileSystem.DotNet.csproj" />
    <ProjectReference Include="..\..\src\FubarDev.FtpServer\FubarDev.FtpServer.csproj" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.0.0" />
  </ItemGroup>

</Project>

2. Enable logging in Program.cs

Change the CreateWebHostBuilder function to:

        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .ConfigureLogging(lb => {
                    lb.AddConsole();
                })
                .ConfigureServices(
                    services =>
                    {
                        services
                           .AddFtpServer(
                                builder => builder
                                   .UseDotNetFileSystem()
                                   .EnableAnonymousAuthentication())
                           .AddHostedService<HostedFtpService>();
                    })
                .UseStartup<Startup>();

3. Start the server

sudo ASPNETCORE_ENVIRONMENT=Development ./QuickStart.AspNetCore > out.log 2>&1

4. Clean-up the log

Remove any sensitive information (if there is any at all), like server IP, user name, etc...

5. Provide additional information