Closed Ansssss closed 5 years ago
I cannot reproduce this problem.
It is not an anti-virus problem related to the port. To verify I just started up a netcat process listening on that port and connected to it and exchanged info without problem.
I generated a new csproj file and added it in the samples folder of the FubarDev.FtpServer solution to test it out. It is named ConsoleApp1.csproj and is attached (and github made me rename it to .txt). ConsoleApp1.txt
Okay, I found the problem. I guess that you're using the source code (i.e. a clone of master)? There's a bug (issue #63) that's fixed in 2.2.1 (branch release/2.2.1).
This is the diff:
diff --git a/src/FubarDev.FtpServer/PasvListenerFactory.cs b/src/FubarDev.FtpServer/PasvListenerFactory.cs
index e5dd2cd..b8a71bf 100644
--- a/src/FubarDev.FtpServer/PasvListenerFactory.cs
+++ b/src/FubarDev.FtpServer/PasvListenerFactory.cs
@@ -33,7 +33,7 @@ namespace FubarDev.FtpServer
/// </summary>
/// <param name="serverOptions">FTPServer options.</param>
/// <param name="logger">Logger instance.</param>
- public PasvListenerFactory(IOptions<FtpServerOptions> serverOptions, ILogger<PasvListenerFactory> logger)
+ public PasvListenerFactory(IOptions<FtpServerOptions> serverOptions, ILogger<PasvListenerFactory> logger = null)
{
_log = logger;
if (serverOptions.Value.PasvMinPort > 1023 &&
@@ -41,7 +41,7 @@ namespace FubarDev.FtpServer
{
_pasvMinPort = serverOptions.Value.PasvMinPort;
_pasvMaxPort = serverOptions.Value.PasvMaxPort;
- _log.LogInformation($"PASV port range set to {_pasvMinPort}:{_pasvMaxPort}");
+ _log?.LogInformation($"PASV port range set to {_pasvMinPort}:{_pasvMaxPort}");
_pasvPorts = Enumerable.Range(_pasvMinPort, _pasvMaxPort - _pasvMinPort + 1).ToArray();
}
@@ -106,14 +106,14 @@ namespace FubarDev.FtpServer
// retry if the socket is already in use, else throw the underlying exception
if (se.SocketErrorCode != SocketError.AddressAlreadyInUse)
{
- _log.LogError(se, "Could not create listener");
+ _log?.LogError(se, "Could not create listener");
throw;
}
}
}
// if we reach this point, we have not been able to create a listener within range
- _log.LogWarning("No free ports available for data connection");
+ _log?.LogWarning("No free ports available for data connection");
throw new SocketException((int)SocketError.AddressAlreadyInUse);
}
}
You are correct, I just downloaded a zip of the source. I thought I had version 3.0.0 (that is the product version listed on the FubarDev.FtpServer.dll that was compiled), so I did not think issue #63 would affect that version of code. I must be confused by the branches and what the github page offers for the download. Is the fix not in the master branch?
No, not yet. The master branch is a version between 2.2.1 and 3.0, but I hope to release 3.0 soon, which will be the first step of a larger refactoring effort.
I downloaded the latest code yesterday and built it. The TestFtpServer project will work for me (i.e. I can start it debugging from within Visual Studio and connect to it with a FileZilla client). However, when I tried to make a minimal server example using the library, the server never sends the welcome message after a client connects. I verified with WireShark, only the TCP connection is established, nothing beyond that.
I even tried using the same code another user posted for a fixed bug, but the problem remains the same. Here is the code I am currently using: