This project is read-only.

AutoPassive not working?

Dec 11, 2014 at 9:03 PM
I've written a simple ftp client that worked fine in testing, then failed in production.

After looking at what the TraceListener provided, I tried setting FtpDataConnectionType explicitly, rather than using the default.

We found that these did not work:
  • AutoPassive
  • AutoActive
  • EPSV
  • EPRT
But these did:
  • PASV
  • EPSV
  • PORT
And that confused me. I thought that AutoPassive was supposed to try EPSV, and then if it failed, try PASV. But in my app, it just fails.

Am I expected to handle the exception and retry in my code?
Jan 30, 2015 at 10:08 AM
We faced the same problem.
In order for "AutoPassive" to work as expected (try EPSV, and then PASV), you might need to force IPV4 :
ftpClient.InternetProtocolVersions = FtpIpVersion.IPv4;
The component default is IPV4 | IPV6.

Take a look on the component inner code :
          if (type == FtpDataConnectionType.EPSV || type == FtpDataConnectionType.AutoPassive) {
                if (!(reply = Execute("EPSV")).Success) {
                    // if we're connected with IPv4 and data channel type is AutoPassive then fallback to IPv4
                    if (reply.Type == FtpResponseType.PermanentNegativeCompletion && type == FtpDataConnectionType.AutoPassive && m_stream != null && m_stream.LocalEndPoint.AddressFamily == Sockets.AddressFamily.InterNetwork)
                        return OpenPassiveDataStream(FtpDataConnectionType.PASV, command, restart);
                    throw new FtpCommandException(reply);