Archived Forum Post

Index of archived forum posts

Question:

Cannot connect to Win IoT Ftp server

Aug 17 '17 at 12:56

I am attempting to connect to RaspberryPi 3 Windows 10 IoT which is running ftpd. I can connect to it using Filezilla without any issues. I installed the latest from NuGet in Visual Studio 2017 Enterprise.

Below is the sample code I am using to attempt to connect. It fails at ftp.ConnectAsync() with:

ChilkatLog: Connect_Ftp2: DllDate: May 29 2017 ChilkatVersion: 9.5.0.68 UnlockPrefix: Anything for 30-day trial Architecture: Little Endian; 32-bit VerboseLogging: 0 ProgressMonitoring: enabled: yes heartbeatMs: 0 sendBufferSize: 65536 --ProgressMonitoring ImplicitSsl: 0 AuthTls: 0 AuthSsl: 0 ftpConnect: Hostname: 10.200.10.207 Port: 21 IdleTimeoutMs: 60000 readCommandResponse: Failed to receive more bytes. Failed to read FTP control channel reply. --readCommandResponse initialStatus: 0 initialResponse: --ftpConnect Failed to connect to FTP server. Failed. --Connect_Ftp2 --ChilkatLog


           Chilkat.Ftp2 ftp = new Chilkat.Ftp2();

            bool success;

            //  Any string unlocks the component for the 1st 30-days.
            success = ftp.UnlockComponent("Anything for 30-day trial");
            if (success != true)
            {
                Debug.WriteLine(ftp.LastErrorText);
                return;
            }

            ftp.Hostname = "10.200.10.207";
            ftp.Username = "User";
            ftp.Password = "Password";
            ftp.Port = 21;

            //  Connect and login to the FTP server.
            success = await ftp.ConnectAsync();
            if (success != true)
            {
                Debug.WriteLine(ftp.LastErrorText);
                return;
            }

            //  Set the transfer mode to ASCII
            success = await ftp.SetTypeAsciiAsync();
            if (success != true)
            {
                Debug.WriteLine(ftp.LastErrorText);
                return;
            }

            //  Change to the remote directory where the file will be uploaded.
            success = await ftp.ChangeRemoteDirAsync("junk");
            if (success != true)
            {
                Debug.WriteLine(ftp.LastErrorText);
                return;
            }

            //  Upload a file.
            string localFilename = "hamlet.xml";
            string remoteFilename = "hamlet.xml";

            //  Turn on session logging for the upload:
            ftp.KeepSessionLog = true;

            success = await ftp.PutFileAsync(localFilename, remoteFilename);
            if (success != true)
            {
                Debug.WriteLine(ftp.LastErrorText);
                return;
            }

            //  View the session log.  You can verify visually that
            //  the transfer was in ascii mode.
            Debug.WriteLine(ftp.SessionLog);

            success = await ftp.DisconnectAsync();

            Debug.WriteLine("File Uploaded!");

Answer

Just an update. I added:| int failReason = ftp.ConnectFailReason;

Debug.WriteLine("connect fail reason = " + Convert.ToString(failReason));

Which returns: connect fail reason = 200

I cannot find this reason documented.

Thanks


Answer

200 = Connected, but failed to receive greeting from FTP server.

Source


Answer

Windows Firewall blocks the port. You can make exceptions for particular applications in Windows Firewall (i.e. .exe files). When FileZilla installs, it adds a rule to Windows Firewall to make an exception for it. You need to make an exception for your application's .exe, or just add a rule to Windows Firewall to allow outbound port 21.

It's really important that people understand how their firewalls work - whether it be software or hardware. Take some time to learn about it. Without understanding, 2 things happen:

1) Your system could be insecure without you having a clue.
2) You end up being flummoxed and wasting a good portion of your life wondering why things don't work.


Answer

So, I double checked the firewall yesterday. My project app is set to be allowed through the firewall. Again, I even turned off the firewall. I don't run any 3rd party anti-virus. Just windows Defender. I even turned that off for a test.

I am running Windows 10 Pro. Visual Studios 2017 Enterprise. A Raspberry Pi 3 with Windows IoT installed and running their ftpd daemon.

I will continue working on this issue. I am evaluating this for the company. We are excited to use this if we can.

I am going to work with another person locally to see if we can get this resolved.


Answer

On re-reading the error message, it looks as though the TCP connection was established, but the initial greeting from the FTP server was not received.


Answer

This problem should be fixed here: https://www.nuget.org/packages/Chilkat.uwp/9.5.0.69-pre